Find out if the given tree is BST or
not

If
we just check the root, left, right property of every node, and all
of them are BSTs in themselves, we cannot say the resulting tree is
also BST. For example:

5
/ \
3 7
\
9

In
the above, 3 < 5 < 7 (BST is complete for root and its
immediate children).

Subtrees
(involving node and their immediate children) at 3, 9 and 7 are all
BSTs

Yet
the whole tree is not BST because 9 lies in left subtree of 5

This
indicates, that the test for BST should check to see that all the
nodes lying left to a node should be smaller than that node and the
nodes to the right of a node should all be greater than that node.

Due
to the above property, every node should lie in a range defined by
its closest right and left parents.