Citrix System Inc Interview Question
Software Engineer / Developers/* height of Binary tree recursively */
private static Integer heightRecursively(BinaryTreeNode root) {
int leftHeight, rightHeight;
if (root == null)
return 0;
else {
leftHeight = heightRecursively(root.getLeft());
rightHeight = heightRecursively(root.getRight());
if (leftHeight > rightHeight)
return leftHeight + 1;
else
return rightHeight + 1;
}
}
- Vir Pratap Uttam May 04, 2015