-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
71 lines (61 loc) · 1.53 KB
/
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "list.h"
#include "binomialheap.h"
static void list_(void){
list *lt = list_new();
for (int i = 0; i < 20; ++i) {
list_push_back(lt, i);
list_push_front(lt, i*i + 4);
}
list_traverse(lt);
list_delete(lt, 125);
list_delete(lt, 200);
list_traverse(lt);
printf("%d\n", list_next(lt, lt->head)->value);
for (int i = 0; i < 19; ++i){
type_value v2 = list_pop_front(lt);
printf("%d ", v2);
type_value v1 = list_pop_back(lt);
printf("%d ", v1);
}
printf("\n");
list_clear(lt);
}
static void binomial_heap(void){
BinomialHeap *heap = bheap_init();
Area a;
a.width = 10;
a.height = 1010;
bheap_push(heap, 7, &a);
bheap_push(heap, 15, &a);
bheap_push(heap, 52, &a);
bheap_push(heap, 30, &a);
bheap_push(heap, 26, &a);
bheap_push(heap, 12, &a);
bheap_push(heap, 3, &a);
bheap_push(heap, 11, &a);
bheap_push(heap, 9, &a);
bheap_push(heap, 5, &a);
bheap_push(heap, 6, &a);
bheap_push(heap, 23, &a);
bheap_push(heap, 17, &a);
bheap_push(heap, 10, &a);
bheap_push(heap, 94, &a);
bheap_push(heap, 63, &a);
bheap_push(heap, 72, &a);
bheap_push(heap, 57, &a);
bheap_traverse(heap);
while(!bheap_is_empty(heap)){
ANode *node = bheap_top(heap);
printf("%d ", node->key);
bheap_pop(heap);
}
printf("\n");
bheap_clear(heap);
}
int main(void) {
binomial_heap();
return 0;
}