You are viewing a single comment's thread. Return to all comments →
Short and simple Java code:
boolean checkBST(Node root) { return checkBSTHelper(root, Integer.MIN_VALUE, Integer.MAX_VALUE); } boolean checkBSTHelper(Node root, int low, int high) { if(root == null) return true; return root.data > low && root.data < high && checkBSTHelper(root.left, low, root.data) && checkBSTHelper(root.right, root.data, high); }
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 →
Short and simple Java code: