Given a Binary Search Trees, task is to count the number of nodes which are having special two digit numbers.
Input : 15 7 987 21 Output : 0 Input : 19 99 57 1 22 Output : 2
Algorithm : Iterate through each node of tree recursively with a variable count, and check each node’s data for special two digit number. If it is then increment the variable count. At the end, return count.
Time Complexity : O(N), where N is the number of nodes in Tree.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Binary Search Tree | Set 1 (Search and Insertion)
- Convert a Binary Search Tree into a Skewed tree in increasing or decreasing order
- Count the Number of Binary Search Trees present in a Binary Tree
- Binary Tree to Binary Search Tree Conversion
- Difference between Binary Tree and Binary Search Tree
- Binary Tree to Binary Search Tree Conversion using STL set
- Floor in Binary Search Tree (BST)
- Binary Search Tree | Set 2 (Delete)
- Make Binary Search Tree
- Sum of all the levels in a Binary Search Tree
- Optimal Binary Search Tree | DP-24
- Print all odd nodes of Binary Search Tree
- Print all even nodes of Binary Search Tree
- Binary Search Tree | Set 3 (Iterative Delete)
- Number of pairs with a given sum in a Binary Search Tree
- Inorder Successor in Binary Search Tree
- Print Binary Search Tree in Min Max Fashion
- Threaded Binary Search Tree | Deletion
- How to handle duplicates in Binary Search Tree?
- Double Threaded Binary Search Tree
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.