summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorsoikk2021-10-30 17:17:21 +0200
committersoikk2021-10-30 17:17:21 +0200
commit18b53edf4a8b5a31fbc00f63775134a818de7fc6 (patch)
tree9e82eb57540839f16a3fc25c427fe9cb2a4d7d4c /main.c
downloadsoikk-trees-18b53edf4a8b5a31fbc00f63775134a818de7fc6.tar.xz
soikk-trees-18b53edf4a8b5a31fbc00f63775134a818de7fc6.tar.zst
A simple collection of tree algorithms made while in school (lol)HEADmaster
Diffstat (limited to 'main.c')
-rw-r--r--main.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..5e16d8b
--- /dev/null
+++ b/main.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "trees.h"
+
+int main(){
+ tree_t *t1 = createTree();
+ addNode(t1->root, 1, 'l');
+ addNode(t1->root, 2, 'r');
+ addNode(t1->root->left, 11, 'l');
+ addNode(t1->root->left->left, 111, 'l');
+ addNode(t1->root->right, 22, 'r');
+ addNode(t1->root->right, 21, 'l');
+ printTree(*t1);
+ printf("\nDepth: %d\n", treeDepth(*t1));
+ printf("End node count: %d\n", endNodeCount(*t1));
+ printf("Tree contains 2? %d\n", treeContainsN(*t1, 2));
+ printf("Tree contains 3? %d\n", treeContainsN(*t1, 3));
+ printf("Total number of nodes: %d\n", nodeCount(*t1));
+
+ sortTree(t1);
+ printf("Sorted tree:\n");
+ printTree(*t1);
+ printf("\n");
+ return 0;
+
+}