It depends on how your tree is structured. Do leaf nodes contain pointers to their parents? Or is it that parents contain pointers to their children, and that you're only given the root node and the addresses of the two particular leaf nodes? In the former case, you can do this in O(h) time with constant memory usage.
Rashakil Fol
Super Senior Demiposter
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177