Amazon Interview Question: First interview: Given a node... | Glassdoor

Interview Question

Software Development Engineer I Intern Interview

First interview: Given a node in a binary search tree, find

  its successor (the next highest number). Assume that each node has a parent pointer.

Interview Answer

1 Answer


if the node has a right child, find the min of the right subtree
if the node is a left child, return the parent
otherwise the node is a right child, so travers the parent pointers until you either get to the end, or find the first parent thats bigger.

Interview Candidate on May 30, 2014

Add Answers or Comments

To comment on this, Sign In or Sign Up.