Program for finding maximum depth or height of a binary tree
/** * find height of the tree recursively */ public static int maxHeight() { return maxHeight(root, 0); } private static int maxHeight(Node node, int h) { if (node == null) { return h; } int lh = maxHeight(node.left, h + 1); int rh = maxHeight(node.right, h + 1); return (lh > rh) ? lh : rh; }
Read more ...