diff options
| author | mo khan <mo.khan@gmail.com> | 2020-08-16 19:32:46 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-08-16 19:32:46 -0600 |
| commit | 64343a3ff963511405deda599327945d685facc0 (patch) | |
| tree | 3bd61f466cdd33c973b8512f1da5c8b70b8d0b7b /src/02/03 | |
| parent | 5e11cbbb78956da5dba24120685de5e8d96aa0f1 (diff) | |
Run clang formatter2.0.0
Diffstat (limited to 'src/02/03')
| -rw-r--r-- | src/02/03/btree.c | 19 | ||||
| -rw-r--r-- | src/02/03/btree_test.c | 6 |
2 files changed, 11 insertions, 14 deletions
diff --git a/src/02/03/btree.c b/src/02/03/btree.c index 68c0912..caf8d2c 100644 --- a/src/02/03/btree.c +++ b/src/02/03/btree.c @@ -45,8 +45,7 @@ BTree *btree_initialize(BTree *parent, int data) { * @param tree The binary tree to convert * @return Returns the head of a linked list. */ -List *btree_to_list(BTree *tree) -{ +List *btree_to_list(BTree *tree) { if (tree == NULL) return NULL; @@ -92,8 +91,7 @@ int btree_size(BTree *tree) { * @param tree the subtree to investigate * @return Returns true then subtree can be used as a scapegoat. */ -bool btree_is_scapegoat(BTree *tree) -{ +bool btree_is_scapegoat(BTree *tree) { int size = btree_size(tree); int parent_size = btree_size(tree->parent); @@ -107,18 +105,18 @@ bool btree_is_scapegoat(BTree *tree) * @param tree The tree to rebuild * @return Returns the new binary tree. */ -BTree *btree_rebuild(BTree *tree) -{ +BTree *btree_rebuild(BTree *tree) { List *list = btree_to_list(tree->parent); int mid = (list_size(list) / 2) - 1; List *new_root = list_get(list, mid); - int data = ((BTree*)new_root->data)->data; + int data = ((BTree *)new_root->data)->data; BTree *new_broot = btree_initialize(NULL, data); for (int i = 0; i < list_size(list); i++) { - if (i == mid) continue; + if (i == mid) + continue; - int data = ((BTree*)list_get(list, i)->data)->data; + int data = ((BTree *)list_get(list, i)->data)->data; btree_insert(new_broot, data); } return new_broot; @@ -131,8 +129,7 @@ BTree *btree_rebuild(BTree *tree) * @param tree the subtree to rebalance * @return Returns the new root of the binary tree. */ -BTree *btree_rebalance(BTree *tree) -{ +BTree *btree_rebalance(BTree *tree) { if (!tree->parent) return tree; diff --git a/src/02/03/btree_test.c b/src/02/03/btree_test.c index 87debc6..d24493a 100644 --- a/src/02/03/btree_test.c +++ b/src/02/03/btree_test.c @@ -110,8 +110,7 @@ Ensure( assert_that(tree->right->right->data, is_equal_to(5)); } -Ensure(BinaryTree, when_calculating_the_size_of_the_tree) -{ +Ensure(BinaryTree, when_calculating_the_size_of_the_tree) { BTree *tree = btree_insert(NULL, 1); tree = btree_insert(tree, 5); tree = btree_insert(tree, 2); @@ -142,7 +141,8 @@ TestSuite *binary_search_tree_tests() { suite, BinaryTree, when_inserting_items_described_in_the_assignment_it_inserts_in_the_expected_position_in_the_tree); - add_test_with_context(suite, BinaryTree, when_calculating_the_size_of_the_tree); + add_test_with_context(suite, BinaryTree, + when_calculating_the_size_of_the_tree); return suite; } |
