Question bank › Binary Search Tree
Dsa Binary Search Tree Warm-up

Count Nodes at Depth in BST

Create a program that counts how many nodes are present at a certain depth in a binary search tree (BST). The depth of the root node is considered 0. Input Format: The first line contains an integer N - the number of nodes in the BST. The next N lines contain the integer values of the nodes. The last line contains a single integer D - the depth for which you want to count the nodes. Output Format: Output the count of nodes present at depth D. Example: Input: 5 4 2 6 1 3 2 Output: 2

Key concepts

binary_search_treedepth_countingtree_traversal

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
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.