Dsa
Binary Search Tree
Warm-up
The Lone Sentinel
In a network topology represented by a BST, a 'Sentinel' is a node that has exactly one child. These nodes are critical because they represent single points of failure. Given an insertion sequence for a BST, count the total number of Sentinel nodes.
Input Format:
A single line of space-separated integers.
Output Format:
An integer representing the count of nodes with exactly one child.
Example:
Input:
10 5 15 3 12
Output:
2
(Node 5 has one child 3, and node 15 has one child 12.)
Key concepts
binary_search_treetree_structurerecursion
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now