Amazon.com
3.4 of 5 2,804 reviews
www.amazon.com Seattle, WA 5000+ Employees

Amazon.com Software Design Engineer Interview Question

I interviewed in Seattle, WA and was asked:
"Binary tree with parent pointers, given two nodes find common ancestor."
Tags: data structures, programming
Add Tags [?]
Answer Flag Question

Part of a Software Design Engineer Interview Review - one of 4,146 Amazon.com Interview Reviews

Answers & Comments

0
of 0
votes
Hint: use a hash table
- Interview Candidate on Mar 19, 2009 Flag Response
0
of 0
votes
For each node traversed from the root,
if both values are less than the current Node, then move to the left
if both values are greater than the currentNode, then move to the right,
if the value of current Node is between value 1 and value 2, then you have found the nearest common ancestor.
- Rajiv on Aug 23, 2010 Flag Response
0
of 0
votes
Rajiv, you can't do that is tree is by parent pointers. you need to bubble up from the given nodes and put parents to a hash.
- dantepy on Apr 30, 2011 Flag Response

To comment on this question, Sign In with Facebook or Sign Up


Tags are like keywords that help categorize interview questions that have something in common.

Glassdoor is your free inside look at Amazon.com interview questions and advice. All interview reviews posted anonymously by Amazon.com employees and interview candidates.