3. What will be the output of the following code snippet?
#include <iostream>
#include <climits>
struct Node {
int data;
Node* left;
Node* right;
};
bool isBSTUtil(Node* root, int min, int max) {
if (!root) return true;
if (root->data <= min || root->data >= max) return false;
return isBSTUtil(root->left, min, root->data) && isBSTUtil(root->right, root->data, max);
}
bool isBST(Node* root) {
return isBSTUtil(root, INT_MIN, INT_MAX);
}
int main() {
Node n1 = {10, nullptr, nullptr};
Node n2 = {5, nullptr, nullptr};
Node n3 = {15, nullptr, nullptr};
n1.left = &n2;
n1.right = &n3;
std::cout << (isBST(&n1) ? "Yes" : "No") << std::endl;
return 0;
}