From 5699b6c7a74cdf6880f33df7f6877c054c62909f Mon Sep 17 00:00:00 2001 From: Udhay <72250606+Udhay-Brahmi@users.noreply.github.com> Date: Fri, 25 Dec 2020 08:05:45 +0530 Subject: [PATCH] Create Count Leaves in Binary Tree --- Count Leaves in Binary Tree | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Count Leaves in Binary Tree diff --git a/Count Leaves in Binary Tree b/Count Leaves in Binary Tree new file mode 100644 index 0000000..d426810 --- /dev/null +++ b/Count Leaves in Binary Tree @@ -0,0 +1,15 @@ +int c=0; +void fun(Node *root){ + if(!root)return; + fun(root->left); + if(root->left!=NULL || root->right!=NULL){c++;} + fun(root->right); +} +int countNonLeafNodes(Node* root) +{ + // Code here + fun(root); + int y=c; + c=0; + return y; +}