Write production quality code to find whether a given binary tree is a BST or not. You can't make any global variable.
Sigiloso
A BST rooted at node N is defined such that all nodes to the left of N are less or equal to N, and all nodes to the right of N are greater or equal to N. And the left and right subtrees are BST as well. boolean isBST(Node N) { if (N == null) return true; Node L = N.left; Node R = N.right; boolean LV = L != null ? L.value = N.value : true; return LV && RV && isBST(N.left) && isBST(N.right); }