Amazon.com Interview Question
1,567 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 In Test at Amazon.com:
First explain what a tree, then binary tree, then a binary search tree is. Now implement a function that verifies whether a binary tree is a valid binary search tree.
| Tags: | binary search tree, validation See more , See less 8 |
See more for this Amazon.com Software Development Engineer In Test Interview
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (2)
0 of 1 people found this helpful
int ret1, ret2;
if (tree == NULL)
return 1;
else {
if (tree->left != NULL){
if (tree->data > tree-left->data){
ret1 = validate_BSR(tree->left);
}
else
return 0;
}
if (tree->right != NULL) {
if (tree->data < tree->right->data){
ret2 = vaidate_BSD(tree->right);
}
else
return 0;
}
return (ret1 == 1 && ret2 == 1)? 1: 0;
}
return 0;
}
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: