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
Something like the following should work
boolean check(Node root) {
if (root == null) {
return true;
}
if (root.left != null && max(root.left) > root.data ) {
return false
}
if (root.right != null && max(root.right) < root.data ) {
return false;
}
return check(root.left) && check(root.right);
}
Note:
max()