Google Interview Question

Two find the lowest common parent for two nodes in a BST

Interview Answers

Anonymous

May 30, 2012

Didn't get this one

Anonymous

Sep 2, 2012

1. Start with root. 2. Check the current node's value with those of the given nodes. 3. If both the nodes' values are less than that of the root, go to step 2 with left child. 4. If both the nodes' values are greater than that of the root, go to step 2 with right child. 5. If one is less and the other is greater than the root, then you found the least common parent.