• +91 9723535972
  • info@interviewmaterial.com

Data structure Interview Questions and Answers

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

Answer -

int count (struct node* t)  
{  
    if(t)  
    {  
        int l, r;  
        l = count(t->left);  
        r=count(t->right);  
        return (1+l+r);  
    }  
    else   
    {  
        return 0;  
    }  
}  

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners