-
Notifications
You must be signed in to change notification settings - Fork 0
/
120-main.c
57 lines (49 loc) · 1.45 KB
/
120-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
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdlib.h>
#include <stdio.h>
#include "binary_trees.h"
/**
* basic_tree - Build a basic binary tree
*
* Return: A pointer to the created tree
*/
binary_tree_t *basic_tree(void)
{
binary_tree_t *root;
root = binary_tree_node(NULL, 98);
root->left = binary_tree_node(root, 12);
root->right = binary_tree_node(root, 128);
root->left->right = binary_tree_node(root->left, 54);
root->right->right = binary_tree_node(root, 402);
root->left->left = binary_tree_node(root->left, 10);
return (root);
}
/**
* main - Entry point
*
* Return: Always 0 (Success)
*/
int main(void)
{
binary_tree_t *root;
int avl;
root = basic_tree();
binary_tree_print(root);
avl = binary_tree_is_avl(root);
printf("Is %d avl: %d\n", root->n, avl);
avl = binary_tree_is_avl(root->left);
printf("Is %d avl: %d\n", root->left->n, avl);
root->right->left = binary_tree_node(root->right, 97);
binary_tree_print(root);
avl = binary_tree_is_avl(root);
printf("Is %d avl: %d\n", root->n, avl);
root = basic_tree();
root->right->right->right = binary_tree_node(root->right->right, 430);
binary_tree_print(root);
avl = binary_tree_is_avl(root);
printf("Is %d avl: %d\n", root->n, avl);
root->right->right->right->left = binary_tree_node(root->right->right->right, 420);
binary_tree_print(root);
avl = binary_tree_is_avl(root);
printf("Is %d avl: %d\n", root->n, avl);
return (0);
}