You are viewing a single comment's thread. Return to all comments →
Was able to solve it because of your comment. thanks a lot. Here's my code.
static ArrayList<Integer> list = new ArrayList<Integer>(); boolean checkBST(Node root) { inOrder(root); for(int i = 1; i< list.size(); i++){ if(list.get(i)<=list.get(i-1)) return false; } return true; } void inOrder(Node root){ if(root == null) return; inOrder(root.left); list.add(root.data); inOrder(root.right); }
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 →
Was able to solve it because of your comment. thanks a lot. Here's my code.