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