Count Non Leaf Node Tree
int countNonLeafNodes(Node* root)
{
int c=1;
if(root==NULL || (root->left==NULL && root->right==NULL))
return 0;
c+=countNonLeafNodes(root->left);
c+=countNonLeafNodes(root->right);
return c;
}
{
int c=1;
if(root==NULL || (root->left==NULL && root->right==NULL))
return 0;
c+=countNonLeafNodes(root->left);
c+=countNonLeafNodes(root->right);
return c;
}
0 Comments:
Post a Comment