aboutsummaryrefslogtreecommitdiff
path: root/btree.cpp
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2021-11-26 02:25:38 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2021-11-26 02:35:23 +0000
commitb58ee52a8157d971440d6c92a194a92c2d75f83b (patch)
tree26dbc5f1e2adc7e632265f67721530eab44dac7a /btree.cpp
parent516325444fc6e109e6fcb0afc895ca6434499c53 (diff)
downloadalgorithms-b58ee52a8157d971440d6c92a194a92c2d75f83b.tar.gz
algorithms-b58ee52a8157d971440d6c92a194a92c2d75f83b.tar.bz2
algorithms-b58ee52a8157d971440d6c92a194a92c2d75f83b.zip
(General)~forgot to format my files
Need to remember to format before each commit
Diffstat (limited to 'btree.cpp')
-rw-r--r--btree.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/btree.cpp b/btree.cpp
index 8c32b1f..741c8f7 100644
--- a/btree.cpp
+++ b/btree.cpp
@@ -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 << ", "