I\'m trying to solve this problem but I\'m having some troubles:
In a binary search tree (BST):
- The data value of every node in a
Your recursion logic is not proper. I am giving here cpp logic. You may need to translate it to Java code.
bool check(Node *root) {
static Node *prev = NULL;
if(root) {
If(!check(root->left)) return false;
If(prev != Null && prev->data > root->data) return false;
Prev = root;
return check(root->right);
}
return true;
}