Interview Question

Software Development Engineer Intern Interview

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

Answer

Interview Answer

1 Answer

0

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 question, Sign In with Facebook or Sign Up