Preview:
 bool solve(Node* root,int mini,int maxi)
    {
        if(!root)
        return true;
        if(root->data>mini and root->data<maxi)
        {
            bool lefti=solve(root->left,mini,root->data);
            bool righti=solve(root->right,root->data,maxi);
             if(lefti and righti)
        return true;
        }
       return false;
    }
    bool isBST(Node* root) 
    {
        return solve(root,INT_MIN,INT_MAX);
    }
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter