WAP to check if a given tree is a BST.