Following function is supposed to calculate the maximum depth or height of a Binary tree -- the number of nodes along the longest path from the root node down to the farthest leaf node. code example
Example: height of a binary tree
int height(Node* root)
{
// Base case: empty tree has height 0
if (root == nullptr)
return 0;
// recur for left and right subtree and consider maximum depth
return 1 + max(height(root->left), height(root->right));
}