CTree/src/main.c
2024-03-27 10:00:11 +01:00

32 lines
699 B
C

#include <stdio.h>
#include <stdlib.h>
#include "tree.h"
int main(void) {
Tree tree = {NULL};
// Some test insertions
tree_insert(&tree, 1);
tree_insert(&tree, 2);
tree_insert(&tree, 3);
// Check size and print inorder
printf("Tree size: %d\n", tree_size(tree.root));
tree_inorder(tree.root);
printf("Tree contains 2: %d\n", tree_contains(tree.root, 2));
// Clear the tree
tree_clear(&tree);
// Check if the tree is really empty
if (tree.root == NULL) printf("Tree is empty\n");
else printf("Tree is not empty: %d\n", tree.root->data);
// Check size and print inorder
printf("Tree size: %d\n", tree_size(tree.root));
tree_inorder(tree.root);
return 0;
}