You are viewing a single comment's thread. Return to all comments →
I did the same. But it's not working.
Here is my code. Can you review it please?
vector <int> inorder_nodes; void Traverse_Inorder(Node *root) { if(root->left != NULL) Traverse_Inorder(root->left); inorder_nodes.push_back(root->data); if(root->right != NULL) Traverse_Inorder(root->right); } bool checkBST(Node* root) { bool result=true; Traverse_Inorder(root); for (int i = 0; i < inorder_nodes.size(); i++) { if(inorder_nodes[i] > inorder_nodes[i+1]) { result = false; break; } } return result; }
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 did the same. But it's not working.
Here is my code. Can you review it please?