public boolean isBinarySearchTree() {
return isBinaryTree(this, (-10^23), 10^23);
}
private boolean isBinarySearchTree(BinaryTree T, int min, int max) {
if(T==null) return true;
if(T.data>min && T.data<max
&& isBinaryTree(T.left, min, T.data)
&& isBinaryTree(T.right, T.data, max))
return true;
return false;
}
No comments:
Post a Comment