Answer:
{
if(root==NULL)
return 0;
int l_height=height(root->left);//calculating height of left subtree.
int r_height=height(root->right);//calculating height of right subtree.
return 1+max(l_height,r_height);//returning the maximum from left and right height and adding 1 height of root.
}
Step-by-step explanation:
The above written program is in C++.It find the height of a maximum height of the binary tree.The function uses recursion to find the height.
First the left subtree's height is calculated then right subtree's then finding the maximum from both of them and adding 1 height of the root.