Check if a tree is a BST or not