diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2021-11-23 06:20:24 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2021-11-23 06:20:39 +0000 |
commit | 516325444fc6e109e6fcb0afc895ca6434499c53 (patch) | |
tree | d8014527db09c112f3041ae501da8885804fe17f | |
parent | 55a24fc5601e05c7dfad9149bc93ac44302f94ae (diff) | |
download | algorithms-516325444fc6e109e6fcb0afc895ca6434499c53.tar.gz algorithms-516325444fc6e109e6fcb0afc895ca6434499c53.tar.bz2 algorithms-516325444fc6e109e6fcb0afc895ca6434499c53.zip |
(btree)+basic main test for insert
-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; +} |