public static int getDiameter(BinaryTreeNode root) { if (root == null) return 0; int rootDiameter = getHeight(root.getLeft()) + getHeight(root.getRight()) + 1; int leftDiameter = getDiameter(root.getLeft()); int rightDiameter = getDiameter(root.getRight()); return Math.max(root...
Tree: Height of a Binary Tree You are viewing a single comment's thread.Return to all comments → coeus 8 years ago For anyone having problem in sample test case. Please note down that they have considerd height of root as '-1'. So your program should return '-1' when root is ...