-
Notifications
You must be signed in to change notification settings - Fork 0
/
100-main.c
51 lines (46 loc) · 1.27 KB
/
100-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
#include <stdlib.h>
#include <stdio.h>
#include "binary_trees.h"
/**
* launch_test - Test ancestor function and print informations
*
* @n1: First node
* @n2: Second node
*/
void launch_test(binary_tree_t *n1, binary_tree_t *n2)
{
binary_tree_t *ancestor;
ancestor = binary_trees_ancestor(n1, n2);
printf("Ancestor of [%d] & [%d]: ", n1->n, n2->n);
if (!ancestor)
{
printf("(nil)\n");
} /* End if */
else
{
printf("%d\n", ancestor->n);
} /* End else */
} /* End function */
/**
* main - Entry point
*
* Return: Always 0 (Success)
*/
int main(void)
{
binary_tree_t *root;
root = binary_tree_node(NULL, 98);
root->left = binary_tree_node(root, 12);
root->right = binary_tree_node(root, 402);
root->left->right = binary_tree_node(root->left, 54);
root->right->right = binary_tree_node(root->right, 128);
root->left->left = binary_tree_node(root->left, 10);
root->right->left = binary_tree_node(root->right, 45);
root->right->right->left = binary_tree_node(root->right->right, 92);
root->right->right->right = binary_tree_node(root->right->right, 65);
binary_tree_print(root);
launch_test(root->left, root->right);
launch_test(root->right->left, root->right->right->right);
launch_test(root->right->right, root->right->right->right);
return (0);
} /* end function */