You are viewing a single comment's thread. Return to all comments →
I am not finding the maximum of minimum. I'm just verifying whether the left and right are smaller/larger respectively. Here is the code.
int check(Node* root,int val) { if(root==NULL) return val; if(root->left) { if(root->left->data >= root->data) val++; else val+=check(root->left,val); } if(root->right) { if(root->right->data <= root->data) val++; else val+=check(root->right,val); } return val; } bool checkBST(Node* root) { int i=check(root,0); if(i==0) return true; else return false; }
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 →
I am not finding the maximum of minimum. I'm just verifying whether the left and right are smaller/larger respectively. Here is the code.