finding maximum depth in BST
1 Answer
finding maximum depth in BST
| Flag | PURGE
can this be solved this way ?
int maxDepth(struct node* node)
{
if (node==NULL)
return 0;
else
{
/* compute the depth of each subtree */
int lDepth = 1 + maxDepth(node->left);
int rDepth = 1 + maxDepth(node->right);
if (lDepth > rDepth)
return(lDepth);
else return(rDepth);
}
}
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
Email me when people comment.
Email me when people comment.
Loading...
An error occurred in subscribing you.
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Looks right.
- Anonymous October 01, 2012