Formatting
This commit is contained in:
parent
c49f02d8d7
commit
5b7efc9ef3
3 changed files with 62 additions and 65 deletions
15
src/tree.c
15
src/tree.c
|
@ -24,7 +24,8 @@ int tree_insert(Tree *tree, int data) {
|
||||||
// If larger than data
|
// If larger than data
|
||||||
if (new_node->data > cursor->data) {
|
if (new_node->data > cursor->data) {
|
||||||
// If there is a child to the right
|
// If there is a child to the right
|
||||||
if(cursor->right != NULL) cursor = cursor->right;
|
if (cursor->right != NULL)
|
||||||
|
cursor = cursor->right;
|
||||||
else {
|
else {
|
||||||
cursor->right = new_node; // Put our node here
|
cursor->right = new_node; // Put our node here
|
||||||
break; // Break the outer while loop
|
break; // Break the outer while loop
|
||||||
|
@ -34,23 +35,19 @@ int tree_insert(Tree *tree, int data) {
|
||||||
// If less-or-equal than our data
|
// If less-or-equal than our data
|
||||||
if (new_node->data <= cursor->data) {
|
if (new_node->data <= cursor->data) {
|
||||||
// If there is a child to the left
|
// If there is a child to the left
|
||||||
if(cursor->left != NULL) cursor = cursor->left;
|
if (cursor->left != NULL)
|
||||||
|
cursor = cursor->left;
|
||||||
else {
|
else {
|
||||||
cursor->left = new_node; // Put our node here
|
cursor->left = new_node; // Put our node here
|
||||||
break; // Break the outer while loop
|
break; // Break the outer while loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tree_remove(Tree *tree, int data) {
|
int tree_remove(Tree *tree, int data) { return 1; }
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tree_clear(Tree *tree) {
|
int tree_clear(Tree *tree) { return 1; }
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tree_size(Tree *tree) {
|
int tree_size(Tree *tree) {
|
||||||
if (tree->root == NULL) {
|
if (tree->root == NULL) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue