Skip to content

Commit

Permalink
#TREE #BST
Browse files Browse the repository at this point in the history
  • Loading branch information
codewithshailendra authored Aug 19, 2019
1 parent 976e70e commit 757dced
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CHECK FOR BST
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


bool fun(Node*root, int mini=INT_MIN,int maxi=INT_MAX) {

if(root==NULL)
return true;

if(root->data>mini && root->data<maxi && fun(root->left,mini,root->data) && fun(root->right,root->data,maxi))
return true;

return false;

}

bool isBST(Node*root)
{
return fun(root);
}

0 comments on commit 757dced

Please sign in to comment.