program to find the height of binary tree

Given a binary tree, find its height.


Example 1:

Input:
     1
    /  \
   2    3
Output: 2

Example 2:

Input:
  2
   \
    1
   /
 3
Output: 3   


ans : 



 int height(struct Node* node)

{

    if(node == NULL)

         return count;

         

         if(node->left || node->right)

            count;

         

        return (max(height(node->right), height(node->left))+1);

        

        

    

}

Comments