Ah the classic interview question. Recurse Binary Trees. I don't know why they just love to give this one but I have some time off so I thought I would solve it. This is for a github project where I will point interviewers at so maybe they will just believe I can do this stuff.
The key to this is to check the other node in the recursion of the find or it will go down the right or left leg and get lost. There are some good Data Structures articles on BTS that I used to come to this solution. Here you go:
- http://cslibrary.stanford.edu/110/BinaryTrees.html
- http://opendatastructures.org/ods-java/6_1_BinaryTree_Basic_Binary.html