All I need is a simple function that will return the height of the tree. Can someone please tell me what's wrong with this code...
I've done tests and the result is wrong.Code:int bt::tree_height(const node *mytree)
{
if(mytree == NULL)
{
return 0;
}
else
{
return 1 + maximum(tree_height(mytree -> left), tree_height(mytree -> right));
}
}
int bt::maximum(int left, int right)
{
if(left >= right)
return left;
else
return right;
}