#include #include #include using namespace std; #include "treesetbst.h" #include "treesetavl.h" #include "tvector.h" #include "ctimer.h" double stress(TreeSetBST * set, tvector& list) { CTimer timer; timer.Start(); for(int k=0; k < list.size(); k++){ set->insert(list[k]); } timer.Stop(); return timer.ElapsedTime(); } int main(int argc, char * argv[]) { TreeSetBST * avlset = new TreeSetAVL(); TreeSetBST * bstset = new TreeSetBST(); string word; string filename; if (argc > 1) { filename = argv[1]; } else { cout << "filename: "; cin >> filename; } ifstream input(filename.c_str()); tvector list; while (input >> word) { list.push_back(word); } double atime = stress(avlset,list); double btime = stress(bstset,list); // avlset->print(); // avlset->levelPrint(); cout << "avl " << atime << " " << avlset->size() << endl; cout << "bst " << btime << " " << bstset->size() << endl; }