Given a Binary tree, count total number of non-leaf nodes in the tree
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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Count the nodes of the tree which make a pangram when concatenated with the sub-tree nodes
- Complexity of different operations in Binary tree, Binary Search Tree and AVL tree
- Count of all prime weight nodes between given nodes in the given Tree
- Construct XOR tree by Given leaf nodes of Perfect Binary Tree
- Program to count leaf nodes in a binary tree
- Count half nodes in a Binary tree (Iterative and Recursive)
- Count full nodes in a Binary tree (Iterative and Recursive)
- Count of nodes in a Binary Tree whose child is its prime factors
- Count balanced nodes present in a binary tree
- Count nodes with two children at level L in a Binary Tree
- Count nodes from all lower levels smaller than minimum valued node of current level for every level in a Binary Tree
- Count nodes having smallest value in the path from root to itself in a Binary Tree
- Count of nodes in a Binary tree with immediate children as its factors
- Count of nodes in a Binary Tree whose immediate children are co-prime
- Iterative program to count leaf nodes in a Binary Tree
- Count root to leaf paths having exactly K distinct nodes in a Binary Tree
- Count pairs of leaf nodes in a Binary Tree which are at most K distance apart
- Count nodes having highest value in the path from root to itself in a Binary Tree
- Count the number of visible nodes in Binary Tree
- Common nodes in the inorder sequence of a tree between given two nodes in O(1) space
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.