Thursday, January 5, 2012

Find Depth of a binary tree

int BSTree::getDepth(Node* node)
{
if(!node)
return 0;

int ld = getDepth(node->left);
int rd = getDepth(node->right);

return MAX(ld, rd) + 1;
}

No comments:

Post a Comment