Amazon or Microsoft programming interview questions and solutions
Pages
Home
Difficulty - Medium
Difficulty - Advance
Dynamic Programming
Graphs
Suggestions
Wednesday, 8 August 2012
Count the number of elements in a binary tree.
int count(node *r)
{
if(r==NULL)
return 0;
else
{
int c=1;
c+=count(r->left);
c+=count(r->right);
return c;
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment