-
Notifications
You must be signed in to change notification settings - Fork 0
/
14-main.c
executable file
·34 lines (30 loc) · 909 Bytes
/
14-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
#include <stdlib.h>
#include <stdio.h>
#include "binary_trees.h"
/**
* main - Entry point
*
* Return: Always 0 (Success)
*/
int main(void)
{
binary_tree_t *root;
int balance;
root = binary_tree_node(NULL, 98);
root->left = binary_tree_node(root, 12);
root->right = binary_tree_node(root, 402);
binary_tree_insert_right(root->left, 54);
binary_tree_insert_right(root, 128);
binary_tree_insert_left(root, 45);
binary_tree_insert_right(root->left, 50);
binary_tree_insert_left(root->left->left, 10);
binary_tree_insert_left(root->left->left->left, 8);
binary_tree_print(root);
balance = binary_tree_balance(root);
printf("Balance of %d: %+d\n", root->n, balance);
balance = binary_tree_balance(root->right);
printf("Balance of %d: %+d\n", root->right->n, balance);
balance = binary_tree_balance(root->left->left->right);
printf("Balance of %d: %+d\n", root->left->left->right->n, balance);
return (0);
}