Skip to content

Commit 8f09730

Browse files
authored
Create program.cpp
1 parent 6a9ac24 commit 8f09730

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

No. of leaf nodes/program.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
void Inorder(BinaryTreeNode<int> *root,int &c)
2+
{
3+
if(root==NULL)
4+
{
5+
return ;
6+
}
7+
Inorder(root->left,c);
8+
if(root->left==NULL && root->right==NULL)
9+
c++;
10+
Inorder(root->right,c);
11+
}
12+
13+
14+
int noOfLeafNodes(BinaryTreeNode<int> *root){
15+
// Write your code here.
16+
int c=0;
17+
Inorder(root,c);
18+
return c;
19+
20+
}

0 commit comments

Comments
 (0)