Is this method wrong for finding out if the tree is a BST or not? The left subtree of a node contains only nodes with keys less than the node’s key.The right subtree of a node contains only nodes with keys greater than the node’s key.And Both the left and right subtrees must also be binary search trees. My code is:
isBST(struct node* node)
{
if (node == NULL)
return 1;
if (node->left != NULL && node->left->data > node->data)
return 0;
if (node->right != NULL && node->right->data < node->data)
return 0;
if (!isBST(node->left) || !isBST(node->right))
return 0;
return 1;
}