Maximum depth of a tree

Write algo to find the max depth of a binary tree.
Answer:


size_t MaxDepth(Node *root)
{
if(root)
{
return max( MaxDepth(root->left) , MaxDepth(root->right) ) + 1;
}
return 0;
}

No comments: