You are viewing a single comment's thread. Return to all comments →
Here is a clean java solution.
boolean checkBST(Node root) { return check(root,Integer.MIN_VALUE,Integer.MAX_VALUE); } boolean check(Node n, int min, int max){ if(n==null) return true; if(n.data <= min || n.data >= max) return false; return check(n.left, min, n.data) && check(n.right, n.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 →
Here is a clean java solution.