Bobby Marvikuan wrote:Hello can anyone help with this code why the answer here is 17 but according to my logic it should be 8:( I am not getting that public class MinTree { Tree tree = new Tree( 24, new Tree( 45, null , new Tree(8, null , null) ) , new Tree ( 17, new Tree (74 , null , null ) , null ) ); public static void main(String[] args){ MinTree mt = new MinTree(); System.out.println("Minimum is :" + mt.findMin()); } int min = tree.getVal(); public int findMin(){ findMin(min, tree); return min; } public boolean findMin(int min, Tree t){ if(t== null){ return false; } else{ int min1 = t.getVal(); if(min1< min){ System.out.println(min1); this.min = min1; System.out.println(min); } return findMin(min, t.left())||findMin(min, t.right()); } } } class Tree { private int val; private Tree left, right; public Tree(int val, Tree left, Tree right){ this.val = val; this.left = left; this.right = right; } public int getVal(){ return val; } public Tree left(){ return left; } public Tree right(){ return right; } }