diff options
Diffstat (limited to 'binary_search_tool/full_bisect_test/build.c')
-rw-r--r-- | binary_search_tool/full_bisect_test/build.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/binary_search_tool/full_bisect_test/build.c b/binary_search_tool/full_bisect_test/build.c new file mode 100644 index 00000000..ea1c8b49 --- /dev/null +++ b/binary_search_tool/full_bisect_test/build.c @@ -0,0 +1,23 @@ +#include <stdlib.h> +#include "bin-trees.h" + +tree_ptr +new_node (int value) +{ + tree_ptr node = (tree_ptr) malloc (sizeof (tree_ptr)); + node->data = value; + node->left = NULL; + node->right = NULL; + return node; +} + +void +search_tree_insert (tree_ptr *root, int value) +{ + if (*root == NULL) + *root = new_node (value); + else if (value < (*root)->data) + search_tree_insert (&((*root)->left), value); + else if (value > (*root)->data) + search_tree_insert (&((*root)->right), value); +} |