Amazon Interview Question: Write a function to determine... | Glassdoor

Interview Question

Software Development Engineer Intern Interview

Write a function to determine if a tree is a BST.


Interview Answer

1 Answer


Use in-order traversal or track the minimum and maximum for each node and recurse for the entire tree. Return false if the condition is broken; true if it holds for the given tree. (Be careful: the minimum/maximum condition should hold across all levels!)

Interview Candidate on Sep 15, 2013

Add Answers or Comments

To comment on this, Sign In or Sign Up.