Assuming this isn't a homework exercise...

> 1)  If current node is empty then this portion of tree is a BST
> 2)  if the left subtree and right subtree's are both not empty then ...

The logical negation of your second clause (which is what is picked
up by the 'otherwise' clause of your code) is that if _either_
subtree is empty, then this portion of the tree is _not_ a BST.
(In other words, it negates the effect of the first clause.)  So all
non-Nil trees will yield False, since everything immediately above a
Nil node is not a BST.  You probably want to change the condition thus:

> isBST thetree
>   | isNil thetree = True
>   | (isBST (leftSub thetree)) && (isBST (rightSub thetree) = checkL && checkR
>   | otherwise = False

Regards,
    Malcolm


Reply via email to