GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Placement Papers  >  Adobe  >  Placement Papers

 Print  |  
Question:  how will you find the number of leaf nodes in a tree



October 10, 2009 17:01:34 #2
 shashankjo   Member Since: October 2009    Total Comments: 1 

RE: how will you find the number of leaf nodes in a tree
 
 
   int count=0;     // global variable

 int inorder(NODE *root)
  {
       if(root!=NULL)
       {
         inorder(root->left);
         if(root->left==NULL && root->right==NULL)
         count++;
         inorder(root->right);
        }
     return (count);
}
     

 

Back To Question