C and C++ programs and MySQL
Always thinking in engineering style...
Thursday, September 17, 2009
Write a C program to determine the number of elements (or size) in a tree.
Try this C program
int tree_size(struct node* node)
{
if (node==NULL)
{
return(0);
}
else
{
return(tree_size(node->left) + tree_size(node->right) + 1);
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment