Complete the code to check if the current node is NULL.
if (root [1] NULL) return 1;
We check if the node is NULL using '=='. If it is NULL, it means the subtree is empty and thus a valid BST.
Complete the code to check if the current node's value is within the allowed range.
if (root->data [1] min || root->data [2] max) return 0;
The node's data must be greater than min and less than max. So we check if it is less than or equal to min or greater than or equal to max to return false.
Fix the error in the recursive call to validate the left subtree.
return isBST(root->left, min, [1]) && isBST(root->right, root->data, max);
For the left subtree, the maximum allowed value is the current node's data, so we pass root->data as the new max.
Fill both blanks to complete the recursive call for the right subtree and the initial call to isBST.
return isBST(root->left, min, [1]) && isBST(root->right, [2], max);
For the left subtree, max is root->data. For the right subtree, min is root->data. This keeps values strictly less or greater than current node.
Fill the three blanks to complete the isBST function signature. Note that the initial call uses INT_MIN and INT_MAX for the full integer range.
int isBST(struct Node* [1], int [2], int [3]) { if (root == NULL) return 1; if (root->data <= min || root->data >= max) return 0; return isBST(root->left, min, root->data) && isBST(root->right, root->data, max); } // Initial call int result = isBST(root, INT_MIN, INT_MAX);
The function takes a pointer named root and two integers min and max. The initial call uses the full integer range as min and max.
