diff options
Diffstat (limited to 'btree.cpp')
-rw-r--r-- | btree.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -3,6 +3,7 @@ * Author: Aryadev Chavali */ +#include <iostream> enum Order { @@ -50,3 +51,27 @@ BinaryTree<T> *insert(BinaryTree<T> *tree, T value) return tree; } +int main(void) +{ + auto tree = new BinaryTree<int>; + tree->value = 5; + tree->compare = [](int x, int y) { + if (x < y) + return LT; + else if (x > y) + return GT; + else + return EQ; + }; + + for (int i = 0; i <= 5; ++i) + { + tree = insert(tree, i * 2); + } + + std::cout << tree->left->value << ", " + << tree->value << ", " + << tree->right->value << std::endl; + delete tree; + return 0; +} |