Amazon.com Interview Question
1,569 Interview Reviews |
Back to all Amazon.com Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Software Development Engineer Intern at Amazon.com:
Given two nodes that are in a binary search tree (this is guaranteed) find the shortest traversal path between them.
See more for this Amazon.com Software Development Engineer Intern Interview
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (5)
1 of 1 people found this helpful
Helpful Answer?
Yes |
No
Inappropriate?
1 of 1 people found this helpful
Yes, that's correct.
Helpful Answer?
Yes |
No
Inappropriate?
if (node1 < node && node2 > node) return node;
else if (node1> node and node2 > node) node = node.right;
else if (node1< node and node2<node ) node = node.left;
}
Helpful Answer?
Yes |
No
Inappropriate?
To comment on this
question,
Sign In with Facebook or
Sign Up



0 of 0 people found this helpful
by Interview Candidate:
That was my solution. it works, but I didn't have time to look into any special cases, debugging, optimization, etc. I'm sure there is a much simpler/efficient way.
Dijkstra's Algorithm came to mind, but I couldn't remember it in detail off of the top of my head at that moment.