Part 11 of 15 in Binary Trees  

Find maximum depth or height of a binary tree by animeshn

Problem statement

Height of a tree is the length of the longest downward path from root to a left. Given a binary tree, find its height. If tree is empty, its height is -1. A tree with only root node has height 0.


You only need to write a function in C/C++ named "FindBinaryTreeHeight" that should take pointer to root as argument and return height of tree as integer.


Your function must return height of tree as integer.

1) input can be empty tree (root == NULL). Height will be -1 in this case.
2) Height of a tree with only one node would be 0.

To try out your code

Sign in

Sign up