This is a c++ binary search program I worked so far but still cant get it right. Can anyone help me? Big thanks!! the client should not be modified /* *File: client.cpp *Author: Yingwu Zhu *Warning: do not change this file and use it as is. *Last Modififcation: 10/21/2016 */ #include #include #include #include #include #include \"bst.h\" using namespace std; int main(int argc, char* argv[]) { if (argc != 2) { cout << \"Format: \" << argv[0] << \" [data file]\" << endl; return 0; } ifstream fin(argv[1]); int cases; fin >> cases; int passed = 0; for (int i = 1; i <= cases; i++) { cout << \"Checking test case #\" << i << \" ... \"; BST T; set S; int n, x; fin >> n; bool ok = true; vector tmp; int rem = 0; for (int j = 0; j < n; j++) { fin >> x; T.Insert(x); S.insert(x); ok &= (T.Search(x) && T.RecurSearch(x)); if (tmp.empty()) tmp.push_back(x); if (rand()%10 < 3) { T.Erase(tmp[0]); S.erase(tmp[0]); ok &= (T.Search(tmp[0]) == false); tmp.pop_back(); rem++; } } if (rem ok &= (T.MaxElement() == *S.rbegin()); while (!S.empty() && !T.Empty()) { int x = T.MinElement(); ok &= (x == *S.begin()); T.Erase(x); S.erase(S.begin()); } cout << (ok ? \"Passed!\" : \"Failed\") << endl; passed += ok; } cout << passed << \" of \" << cases << \" test cases have passed!\ \"; if (passed == cases) cout << endl << \"Congratulations! Good to Submit Your Code\ \"; else if ((double)passed/cases >= 0.95) cout << endl << \"You are almost there, but need to fix some bugs.\ \"; else cout << endl << \"Your code needs a lot of fixes for submission\ \"; return 0; } ===================================================================== ======= //bst.h #ifndef _BST_H_ #define _BST_H_ #include using namespace std; class BST { private: class Node { public: int data; Node* left; Node* right; }; Node* root; //root node pointer //you may add your auxiliary functions here! public: BST(); //constructor ~BST(); //destructor bool Empty() const; void Insert(int val); int MinElement() const; int MaxElement() const; bool Search(int val) const; bool RecurSearch(int val) const; void Erase(int val); }; #endif ===================================================================== ======= /* bst.cpp Subject: Binary Seach Tree Modification Time:10/26/2016 */ #include #include\"bst.h\" using namespace std; BST::BST(){ root= NULL; } BST::~BST(){ delete root; delete root->left; delete root->right; } bool BST::Empty() const { return data; } void BST::Insert(int val){ Node* p= new Node; p->data= val; Node* cur = root; if(val < cur->data){ cur = cur -> left; } else{ right->next=val; } } int BST::MinElement() const { Node* cur; while(cur->left != NULL){ cur = cur->left; } return(cur->data); } int BST::MaxElement() const{ if(root==NULL){ return 0; } if(root->left>root->data){ root->data=root->right; } else if(root->right>root->data){ root->data=root->right; } return root->data; } bool BST:: Search(int val) const{ Node* cur; cur = root; while(cur!=NULL){ if(cur->data == val){ return true; } else if(cur->data .