You are viewing a single comment's thread. Return to all comments →
Java
boolean checkBST(Node root) { return recursiveCheck(root, -1, 10001); } boolean recursiveCheck(Node root, int min, int max){ if(root == null) return true; if(root.data <= min || root.data >= max) return false; return(recursiveCheck(root.left, min, root.data) && recursiveCheck(root.right, root.data, max)); }
Seems like cookies are disabled on this browser, please enable them to open this website
Trees: Is This a Binary Search Tree?
You are viewing a single comment's thread. Return to all comments →
Java