Given a root note, confirm whether or not the given tree is a BST.
Anonymous
boolean isBST(TreeNode[] root){ return isBSTU(root, Integer.MIN_VALUE, Integer.MAX_VALUE); } boolean isBSTU(TreeNode root, int min, int max){ if(root==null) return true; if(root.valmax) return false; return (isBSTU(root.left,min,root.data-1) && isBSTU(root.right,root,data+1,max)); }
Check out your Company Bowl for anonymous work chats.