Given a Binary tree, count total number of non-leaf nodes in the tree
Input : Output :2 Explanation In the above tree only two nodes 1 and 2 are non-leaf nodes
We recursively traverse the given tree. While traversing, we count non-leaf nodes in left and right subtrees and add 1 to the result.
- Program to count leaf nodes in a binary tree
- Count full nodes in a Binary tree (Iterative and Recursive)
- Iterative program to count leaf nodes in a Binary Tree
- Count half nodes in a Binary tree (Iterative and Recursive)
- Sum of all nodes in a binary tree
- Count greater nodes in AVL tree
- Sum of all leaf nodes of binary tree
- Sink Odd nodes in Binary Tree
- Product of all nodes in a Binary Tree
- Count the number of nodes at given level in a tree using BFS.
- Given a binary tree, how do you remove all the half nodes?
- Print Nodes in Top View of Binary Tree
- Check if two nodes are cousins in a Binary Tree
- Sum of nodes at maximum depth of a Binary Tree
- Check if two nodes are cousins in a Binary Tree | Set-2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.