**Given a binary tree, find its maximum height.**

**The maximum height of a binary tree is defined as the number of nodes along the path from the root node to the deepest leaf node. Note that the maximum height of an empty tree is 0.**

C++:

01 int maxHight(Node* head)

02 {

03 if(head==NULL)

04 return 0;

05 int left=maxHight(head->left);

06 int right=maxHight(head->right);

07 if(left>=right)

08 return left+1;

09 else

10 return right+1;

11 }

02 {

03 if(head==NULL)

04 return 0;

05 int left=maxHight(head->left);

06 int right=maxHight(head->right);

07 if(left>=right)

08 return left+1;

09 else

10 return right+1;

11 }

Advertisements