-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path123-main.c
45 lines (38 loc) · 951 Bytes
/
123-main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <stdlib.h>
#include "binary_trees.h"
/**
* main - Entry point
*
* Return: 0 on success, error code on failure
*/
int main(void)
{
avl_t *tree;
int array[] = {
79, 47, 68, 87, 84, 91, 21, 32, 34, 2,
20, 22, 98, 1, 62, 95
};
size_t n = sizeof(array) / sizeof(array[0]);
tree = array_to_avl(array, n);
if (!tree)
return (1);
binary_tree_print(tree);
tree = avl_remove(tree, 47);
printf("Removed 47...\n");
binary_tree_print(tree);
tree = avl_remove(tree, 79);
printf("Removed 79...\n");
binary_tree_print(tree);
tree = avl_remove(tree, 32);
printf("Removed 32...\n");
binary_tree_print(tree);
tree = avl_remove(tree, 34);
printf("Removed 34...\n");
binary_tree_print(tree);
tree = avl_remove(tree, 22);
printf("Removed 22...\n");
binary_tree_print(tree);
binary_tree_delete(tree);
return (0);
}