From 18b53edf4a8b5a31fbc00f63775134a818de7fc6 Mon Sep 17 00:00:00 2001 From: soikk Date: Sat, 30 Oct 2021 17:17:21 +0200 Subject: A simple collection of tree algorithms made while in school (lol) --- main.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 main.c (limited to 'main.c') 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 +#include +#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; + +} -- cgit v1.2.3