You are viewing a single comment's thread. Return to all comments →
You can change the last if condition via DeMorgan's law to make this even simpler!
boolean checkBST(Node root, int min, int max) { if (root == null) return true; if (root.data <= min || root.data >= max) return false; return checkBST(root.left, min, root.data) && checkBST(root.right, root.data, max)); }
Seems like cookies are disabled on this browser, please enable them to open this website
Is This a Binary Search Tree?
You are viewing a single comment's thread. Return to all comments →
You can change the last if condition via DeMorgan's law to make this even simpler!