diff options
Diffstat (limited to 'btree.cpp')
-rw-r--r-- | btree.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -40,22 +40,24 @@ BinaryTree<T> *insert(BinaryTree<T> *tree, T value) break; } - if (*node) { + if (*node) + { *node = insert(*node, value); return tree; } - *node = new BinaryTree<T>; + *node = new BinaryTree<T>; (*node)->value = value; (*node)->left = (*node)->right = nullptr; - (*node)->compare = tree->compare; + (*node)->compare = tree->compare; return tree; } int main(void) { - auto tree = new BinaryTree<int>; - tree->value = 5; - tree->compare = [](int x, int y) { + auto tree = new BinaryTree<int>; + tree->value = 5; + tree->compare = [](int x, int y) + { if (x < y) return LT; else if (x > y) @@ -65,9 +67,7 @@ int main(void) }; for (int i = 0; i <= 5; ++i) - { tree = insert(tree, i * 2); - } std::cout << tree->left->value << ", " << tree->value << ", " |