public boolean isBinarySearchTree(){ if(isEmpty()|| isLeaf()) return true; Comparable rootKey = (Comparable) key; if(left.isGreater(rootKey) && right.isLess(rootKey)) return left.isBinarySearchTree() && right.isBinarySearchTree(); else return false; } // returns true if rootKey is less than all keys in the invoking tree; otherwise false private boolean isLess(Comparable rootKey) { if(isEmpty()) return true; if(rootKey.compareTo((Comparable)key) >= 0) return false; else return getRight().isLess(rootKey) && getLeft().isLess(rootKey); } // returns true if root key is greater than all keys in the invoking tree private boolean isGreater(Comparable rootKey) { if(isEmpty()) return true; if(rootKey.compareTo((Comparable)key) <= 0) return false; else return getRight().isGreater(rootKey) && getLeft().isGreater(rootKey); }