-
-
Save orlp/71b7a2976d82be1b2f6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <vector> | |
#include <string> | |
#include <chrono> | |
#include <memory> | |
#include <cstdlib> | |
#include "splay_tree.h" | |
#include "avl_tree.h" | |
int main(int argc, char** argv) { | |
std::string word; | |
std::vector<std::string> words; | |
std::ifstream input("wordlist1.txt"); | |
while (std::getline(input, word)) { | |
words.push_back(word); | |
} | |
SplayTree<std::string> splay_tree; | |
auto start = std::chrono::high_resolution_clock::now(); | |
for (auto word : words) splay_tree.insert(word); | |
auto end = std::chrono::high_resolution_clock::now(); | |
auto elapsed = end - start; | |
std::cout << "create splay_tree took" << elapsed.count() << " time" << '\n'; | |
AVLTree<std::string> avl_tree; | |
start = std::chrono::high_resolution_clock::now(); | |
for (auto word : words) avl_tree.insert(word); | |
end = std::chrono::high_resolution_clock::now(); | |
elapsed = end - start; | |
std::cout << "create avl_tree took" << elapsed.count() << " time" << '\n'; | |
//for (int i = 1; i <= 25; i++) { | |
// int n = rand() % 50; | |
// tree.remove(tree.search(n)); | |
//} | |
//tree.remove(tree.search(36)); | |
tree.save_as_dot("test.dot"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment