Print all Nodes in the Range a .. b in a given BST
Given a Binary Search Tree and two numbers - 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 ascending order.
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 root is null, return 2. 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.