Write the recursive C function to count the number of nodes present in a binary tree.

bookmark

  1. int count (struct node* t)  
  2. {  
  3.     if(t)  
  4.     {  
  5.         int l, r;  
  6.         l = count(t->left);  
  7.         r=count(t->right);  
  8.         return (1+l+r);  
  9.     }  
  10.     else   
  11.     {  
  12.         return 0;  
  13.     }  
  14. }