diff options
| author | iceyrazor <iceyrazor@mailfence.com> | 2026-05-28 18:49:05 -0500 |
|---|---|---|
| committer | iceyrazor <iceyrazor@mailfence.com> | 2026-05-28 18:49:05 -0500 |
| commit | 53664714b9a693391054d1c0c601b285f2b1a577 (patch) | |
| tree | 0a9f9e6d6dcf61f9f8d13f1e8c45e8ab6b361a9c /src/1-1-binary-search-tree.c | |
init
Diffstat (limited to 'src/1-1-binary-search-tree.c')
| -rw-r--r-- | src/1-1-binary-search-tree.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/1-1-binary-search-tree.c b/src/1-1-binary-search-tree.c new file mode 100644 index 0000000..cb5efc1 --- /dev/null +++ b/src/1-1-binary-search-tree.c @@ -0,0 +1,33 @@ +#include <stdbool.h> +#include <stdio.h> +#include <algolib.c> +#include <vectorlib.c> +#include <time.h> + +typedef struct TREE{ + BS_Node *root; +} TREE; + +int main(int argc, char **argv){ + srand(time(NULL)); + TREE tree = {NULL}; + + for(int i=0; i <40; i++){ + BSAddValue(&tree.root,(int)RandomFloat(0,100)); + } + + BSPrintTree(&tree.root); + BS_Node *found_node = BSSearchTree(&tree.root,53); + if(found_node != NULL) { + printf("53 found %d\n",found_node->value); + } else { + printf("53 not found\n"); + } + BSFreeTree(&tree.root); + return 0; +} + +/* Challanges + * + * balance the tree + */
\ No newline at end of file |
