Program to determine the number of elements (or size) in a tree.

Solution:

int tree_size(struct node* node)  {
  if (node==NULL)
  {
    return(0);
  }
  else
  {
    return(tree_size(node->left) + tree_size(node->right) + 1);
  }  }
 
Top Blogs