aboutsummaryrefslogtreecommitdiff
path: root/src/1-1-binary-search-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/1-1-binary-search-tree.c')
-rw-r--r--src/1-1-binary-search-tree.c33
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