-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
51 lines (36 loc) · 929 Bytes
/
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 <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "twothree_tree.h"
int main(int argc, char *argv[])
{
TTNode *root = NULL;
time_t t;
root = insert(root, root, 10);
for (int i = 20; i < 500; i+= 10)
insert(root, root, i);
printf("in-order display:\n");
in_order(root, 0);
for (int i = 10; i < 500; i+= 10)
{
delete(&root, root, i);
printf("in-order display:\n");
in_order(root, 0);
}
root = insert(root, root, 10);
for (int i = 20; i < 200; i+= 10)
insert(root, root, i);
in_order(root, 0);
srand((unsigned) time(&t));
int k = 0;
for (int i = 0; i < 50; i++) {
k = rand() % 50;
printf("delete %d\n", k * 10);
delete(&root, root, k * 10);
printf("in-order display:\n");
in_order(root, 0);
}
destroy_tt_tree(root);
root = NULL;
return 0;
}