-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
104 lines (103 loc) · 3.95 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <bib.h>
void main(){
int casos = 10000, melhorCaso[casos], casoMedio[casos], piorCaso[casos], x = casos;
double time_spent;
clock_t end, begin;
//Gerando Vetores
for (int i = 0; i<casos; i++){
melhorCaso[i] = i;
casoMedio[i] = rand() % 1000;
piorCaso[i] = x;
x--;
}
//rodando Merge Sort
int *MergePior = copiarVetor(casos, piorCaso);
int *MergeMedio = copiarVetor(casos, casoMedio);
int *MergeMelhor = copiarVetor(casos, melhorCaso);
/***********************************************/
printf("***************************************\n");
printf("Merge Sort | Pior Caso |: ");
begin = clock();
Mergesort(0, casos, MergePior);
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
free(MergePior);
printf("%lf segundos\n", time_spent);
printf("***************************************\n");
/***********************************************/
printf("Merge Sort | Medio Caso |: ");
begin = clock();
Mergesort(0, casos, MergeMedio);
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
free(MergeMedio);
printf("%lf segundos\n", time_spent);
printf("***************************************\n");
/***********************************************/
printf("Merge Sort | Melhor Caso |: ");
begin = clock();
Mergesort(0, casos, MergeMelhor);
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
printf("%lf segundos\n", time_spent);
free(MergeMelhor);
printf("***************************************\n");
/*#############################################*/
//rodando Counting sort
int *CountingPior = copiarVetor(casos, piorCaso);
printf("Counting Sort | Pior Caso |: ");
begin = clock();
countingSort(CountingPior, casos);
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
printf("%lf segundos\n", time_spent);
printf("***************************************\n");
//free(CountingPior);
/***********************************************/
int *CountingMedio = copiarVetor(casos, casoMedio);
printf("Counting Sort | Medio Caso |: ");
begin = clock();
countingSort(CountingMedio, casos);
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
printf("%lf segundos\n", time_spent);
//free(CountingMedio);
printf("***************************************\n");
/***********************************************/
int *CountingMelhor = copiarVetor(casos, melhorCaso);
printf("Counting Sort | Melhor Caso |: ");
begin = clock();
countingSort(CountingMelhor,casos);
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
printf("%lf segundos\n", time_spent);
printf("***************************************\n");
//free(CountingMelhor);
/***********************************************/
//rodando Heap Sort
int *HeapPior = copiarVetor(casos, piorCaso);
printf("Heap Sort | Pior Caso |: ");
begin = clock();
heapsort(HeapPior,casos);
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
printf("%lf segundos\n", time_spent);
printf("***************************************\n");
/***********************************************/
int *HeapMedio = copiarVetor(casos, casoMedio);
printf("Heap Sort | Medio Caso |: ");
begin = clock();
heapsort(HeapMedio,casos);
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
printf("%lf segundos\n", time_spent);
printf("***************************************\n");
/***********************************************/
int *HeapMelhor = copiarVetor(casos, melhorCaso);
printf("Heap Sort | Melhor Caso |: ");
begin = clock();
heapsort(HeapMelhor,casos);
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
printf("%lf segundos\n", time_spent);
}