Amazon.com

  www.amazon.com
Work in HR? Unlock Free Profile

Amazon.com Software Engineer Intern Interview Question (student candidate)

I interviewed in Penn State University, PA and was asked:
"Main question was verifying whether a binary tree was a BST, given the function header that looked like public boolean isBST(root). He stated no other functions could be created and that child nodes did not have links to their parents."
Add Tags [?]
Answer

Part of a Software Engineer Intern Interview Review - one of 4,635 Amazon.com Interview Reviews

Answers & Comments

0
of 0
votes
He was looking for me to use a helper function to pass the parent's value in.

boolean isBST(Node root) {
   return isBSTHelper(root.left, root.value, isLeft) && isBSTHelper(root.right, root.value, isRight);
}

something similar to this. Since he told me I could not use extra functions I could not come up with an answer which is why I am bitter / negative about this interview.
- Interview Candidate on Apr 2, 2014
0
of 0
votes
Basically, what you would have in isBST is the stop condition (i.e. if left < current-node < right), then recursively whether isBST(left) && isBST(right) is true.
- Khoa on Apr 5, 2014

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.