// Oldham, Jeffrey D. // 2000Apr09 // CS1321 // Test Binary Search Trees // Use this file to test the binary search tree routines. #include #include // has EXIT_SUCCESS #include #include #include // has tolower() #include "bst.h" int main() { cout << "Hello, world.\n"; Tree t; const char prompt[]="q: quit\ni: insert\nr: remove\n?: query\np: print\n"; string s; char c; cout << prompt; while (cin >> c) { switch(tolower(c)) { case 'q': return EXIT_SUCCESS; break; case 'i': cout << "Please enter the string to insert: "; if (cin >> s) t = insert(s, t); break; case '?': cout << "Please enter the string to query for: "; if (cin >> s) { if (query(s, t)) cout << "found\n"; else cout << "missing\n"; } break; case 'r': cout << "Please enter the string to remove: "; if (cin >> s) t = remove(s, t); break; case 'p': cout << t; break; } cout << prompt; } assert(false); // impossible to reach here return EXIT_FAILURE; }