You are viewing a single comment's thread. Return to all comments →
bool check(Node *root,int min,int max)
{ if(root!=NULL) { if(root->data>=min || root->data<=max) return false; else return (check(root->left,min,root->data) && check(root->right,root->data,max)); } return true; } bool checkBST(Node* root) { Node *temp1=root; Node *temp2=root; while(temp1->left!=NULL) temp1=temp1->left; while(temp2->right!=NULL) temp2=temp2->right; return check(root,temp1->data,temp2->data); } Can someone please tell me why this code fails for most of the testcases?
Seems like cookies are disabled on this browser, please enable them to open this website
Is This a Binary Search Tree?
You are viewing a single comment's thread. Return to all comments →
bool check(Node *root,int min,int max)