We have already discussed to find largest element in a binary tree using bfs algorithm. Recursive approach to find height of binary tree public int findHeightOfBinaryTreeRecursive Node root if root null return 0 Call function recursively for left and right child and find height of left and right child int lh findHeightOfBinaryTreeRecursive root. Height 1 max ofleft_child_height right_child_height T3 Now with these we can outline the steps to develop a recursive program.
Now that we know what the height of a Binary tree signifies we shall now construct an algorithm to find the height of any Binary Tree.
Since the leaf nodes corresponding to the maximum depth are 40 and 50 to find the height we simply find the number of edges from the root node to either one of these two nodes which is 3. Georg Nov 10 12 at 1405. Recursive approach to find height of binary tree public int findHeightOfBinaryTreeRecursive Node root if root null return 0 Call function recursively for left and right child and find height of left and right child int lh findHeightOfBinaryTreeRecursive root. Int heightNode root return the height of tree ifroot null return -1.