/* Spring 2004 CSCI 2720 Prog. Proj. #2 part I */ /* -------------------------------------------------------------------------- */ /* ifaceP2.cc */ /* main program to test interface to BST< , > class */ /* -------------------------------------------------------------------------- */ /* If the Project #2 interface is correctly implemented in your bst.h and bst.cc files, the this file should compile with the command g++ -o ifaceP2 ifaceP2.cc Once it compiles, the output is self-explanatory, i.e., the outputs of the various member functions should match exactly the outputs predicted by the text directed to cout. Note that this is not an exhaustive test of all the functionality required by the project, or even of the interfaces to all of the public member functions. However the functions used are representative. */ #include "bst.cc" class scmp { public: static int lt(char* const &s1, char* const &s2) { return strcmp(s1, s2); } }; int main( ) { BST Tint; int nn, ht, oh, il; cout << "should be empty:" << endl; Tint.Display_In_Order( ); cout << endl; cout << "tree stats should be 0, -1, 0, 0:\n"; // OR (more natural, really) cout << " or else 0, -1, -1, 0:\n"; Tint.Stats( nn, ht, oh, il ); cout << " " << nn << ", " << ht << ", " << oh << ", " << il << endl; cout << "should be: 1 1 1 0" << endl; cout << " "; cout << Tint.Insert(9); cout << ' ' << Tint.Insert(5); cout << ' ' << Tint.Insert(13); cout << ' ' << Tint.Insert(5) << endl; cout << "should be: 5 9 13" << endl; cout << " "; Tint.Display_In_Order( ); cout << endl; BST Tstrng; cout << "(This should be empty.)" << endl; Tstrng.Display_In_Order( ); cout << endl; cout << "should be: 1 0 1 1 1 1 1 0" << endl; cout << " "; cout << Tstrng.Insert("far!"); cout << ' ' << Tstrng.Remove("It"); cout << ' ' << Tstrng.Insert("well"); cout << ' ' << Tstrng.Insert("so"); cout << ' ' << Tstrng.Insert("works"); cout << ' ' << Tstrng.Insert("It"); cout << ' ' << Tstrng.Remove("well"); cout << ' ' << Tstrng.Insert("so") << endl; cout << "(This should be: It works so far!)\n" << " "; Tstrng.Display_Post_Order( ); cout << endl << endl; return 0; } // end of main( )