Question bank › Binary Search Tree
Dsa Binary Search Tree Medium

Count Nodes at Given Level in BST

Given a binary search tree and a level number (0-indexed), write a program that counts the number of nodes present at that specific level. If the level is out of the bounds of the tree, print '0'. Input Format: - The first line contains an integer N, the number of nodes in the BST. - The next N lines each contain an integer representing a node value. - The last line contains a single integer level. Output Format: - Print the count of nodes at the specified level. Example: Input: 6 3 9 20 15 7 10 2 Output: 2

Key concepts

binary_search_treelevel_traversalcount

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