public class AB3 { public boolean valsLess(TreeNode t, Comparable obj) { if (t == null) return true; Comparable c = (Comparable) t.getValue(); return c.compareTo(obj) < 0 && valsLess(t.getLeft(),obj) && valsLess(t.getRight(), obj); } public boolean valsGreater(TreeNode t, Comparable obj) { if (t == null) return true; Comparable c = (Comparable) t.getValue(); return c.compareTo(obj) > 0 && valsGreater(t.getLeft(),obj) && valsGreater(t.getRight(), obj); } public boolean isBST(TreeNode t) { if (t == null) return true; Comparable c = (Comparable) t.getValue(); return valsLess(t.getLeft(), c) && valsGreater(t.getRight(), c) && isBST(t.getLeft()) && isBST(t.getRight()); } }