Hi,
The problem asks to return a list of all keys in [L, U]. It doesn’t ask the list to be sorted. Isn’t the solution overkilling? Can we just do a traverse instead? If current->data < L, traverse in right subtree only; if current->data > U, traverse in left subtree only; otherwise output current and recursively do the same for left and right. Worse case each node is checked only once, still better than the solution which goes down the tree to find the first node and then come back up when searching for successors, visiting h nodes twice.
Thanks,
Ray