-
Notifications
You must be signed in to change notification settings - Fork 0
/
17-main.c
37 lines (34 loc) · 1.25 KB
/
17-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
#include <stdlib.h>
#include <stdio.h>
#include "binary_trees.h"
/**
* main - Entry point
*
* Return: Always 0 (Success)
*/
int main(void)
{
binary_tree_t *root;
binary_tree_t *sibling;
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->right, 402);
/* root->left->left = binary_tree_node(root->left, 10);*/
root->right->left = binary_tree_node(root->right, 110);
root->right->right->left = binary_tree_node(root->right->right, 200);
root->right->right->right = binary_tree_node(root->right->right, 512);
binary_tree_print(root);
sibling = binary_tree_sibling(root->left);
printf("Sibling of %d: %d\n", root->left->n, sibling->n);
sibling = binary_tree_sibling(root->right->left);
printf("Sibling of %d: %d\n", root->right->left->n, sibling->n);
if (root->left->right)
sibling = binary_tree_sibling(root->left->right);
if (root->left->right)
printf("Sibling of %d: %d\n", root->left->right->n, sibling->n);
sibling = binary_tree_sibling(root);
printf("Sibling of %d: %p\n", root->n, (void *)sibling);
return (0);
}