Please refer below post for details of this function . www . geeksforgeeks . org / a - program - to - check - if - a - binary - tree - is - bst - or - not / https :
static boolean isBST ( Node root , int min , int max ) { if ( root == null ) { return true ; } if ( root . key < min root . key > max ) { return false ; }