Challenge: Print Tree Nodes within a Range

Let’s print nodes within a certain range in a BST.

Problem

Print only those nodes of the tree whose value is in the given range.

Input

Two node values.

Output

An in-order list of the node values.

Sample input

min = 3
max = 9

Sample output

3 4 5 6 7 8 9

Let’s look at the illustration below to better understand the problem.

Get hands-on with 1400+ tech skills courses.