Dsa
Binary Search Tree
Easy
Range Search in BST
Write a program that prints all values in a binary search tree that fall within a given range [low, high]. The tree will be presented via its level-order traversal.
Input Format:
A single line containing integers separated by spaces for the BST followed by two integers for the range low and high on a new line.
Output Format:
Print all integer values that fall within the given range in ascending order, separated by a space. If no values fall in the range, print 'NONE'.
Example:
Input:
5 3 8 1 4 7 10
4 8
Output:
4 5 7 8
Key concepts
binary_search_treerange_querytraversal
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