Given a Binary Search Tree and two numbers - **ascending** order.

`a`

& `b`

, return all the nodes in the tree that lie in the range `[a .. b]`

. Your method should return an `ArrayList`

with the data of the qualifying nodes inserted in Example:

4

/ \

2 8

/ \

5 10

Range (2,8) ==> [2, 4, 5, 8]

Range includes 2 & 8

Need a **hand?** Try out these hints, one at a time.

Use the properties of a BST - all values smaller than a node's value will lie in its left subtree and all larger values will lie in its right subtree. Use this fact and a recursion based approach to solve the problem.

1. If the

2. If

3. If

4. If

`root`

is `null`

, return2. If

`root.data`

is greater than `a`

, recurse through the `left`

subtree with `root.left`

,`a`

and `b`

as inputs. i.e. `printRange(root.left, a, b);`

3. If

`root.data`

is in between `a`

and `b`

, add that to the `ArrayList`

that will be returned.4. If

`root.data`

is less than `b`

, recurse through the `right`

subtree with `root.right`

, `a`

and `b`

as inputs.public ArrayList<Integer> rangeList = new ArrayList<Integer>(); public void printRange(TreeNode root, int a, int b) { }

**C**

**Java**

**Python**