Amazon or Microsoft programming interview questions and solutions
Pages
Home
Difficulty - Medium
Difficulty - Advance
Dynamic Programming
Graphs
Suggestions
Wednesday, 8 August 2012
calculate the depth of the binary tree.
int maxdepth=0;
void depth(node *r,int d)
{
if(r!=NULL)
{
if(maxdepth<d)
maxdepth=d;
depth(r->left,d+1);
depth(r->right,d+1);
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment