// Find height of a tree, defined by the root node
int tree_height(Node* root) {
if (root == NULL)
return 0;
else {
// Find the height of left, right subtrees
left_height = tree_height(root->left);
right_height = tree_height(root->right);
// Find max(subtree_height) + 1 to get the height of the tree
return max(left_height, right_height) + 1;
}
int treeHeight(node* root) {
if(root == NULL)
return 0;
else {
int leftHeight = treeHeight(root->left);
int rightHeight = treeHeight(root->right);
if(leftHeight >= rightHeight)
return leftHeight + 1;
else
return rightHeight + 1;
}
}