3. Given the following tree structure and code snippet, what will be the output?
struct Node {
int data;
struct Node* left;
struct Node* right;
};
int isBSTUtil(struct Node* node, int min, int max) {
if (node == NULL) return 1;
if (node->data <= min || node->data >= max) return 0;
return isBSTUtil(node->left, min, node->data) && isBSTUtil(node->right, node->data, max);
}
int isBST(struct Node* root) {
return isBSTUtil(root, INT_MIN, INT_MAX);
}
// Tree:
// 10
// / \
// 5 15
// / \
// 6 20
int main() {
struct Node n1 = {10, NULL, NULL};
struct Node n2 = {5, NULL, NULL};
struct Node n3 = {15, NULL, NULL};
struct Node n4 = {6, NULL, NULL};
struct Node n5 = {20, NULL, NULL};
n1.left = &n2; n1.right = &n3;
n3.left = &n4; n3.right = &n5;
printf("%d\n", isBST(&n1));
return 0;
}