From 516325444fc6e109e6fcb0afc895ca6434499c53 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Tue, 23 Nov 2021 06:20:24 +0000 Subject: (btree)+basic main test for insert --- btree.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/btree.cpp b/btree.cpp index 0ac794f..8c32b1f 100644 --- a/btree.cpp +++ b/btree.cpp @@ -3,6 +3,7 @@ * Author: Aryadev Chavali */ +#include enum Order { @@ -50,3 +51,27 @@ BinaryTree *insert(BinaryTree *tree, T value) return tree; } +int main(void) +{ + auto tree = new BinaryTree; + 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; +} -- cgit v1.2.3-13-gbd6f