-
Notifications
You must be signed in to change notification settings - Fork 0
/
selectionSort.cpp
86 lines (65 loc) · 1.41 KB
/
selectionSort.cpp
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
#define T25 25000
#define T50 50000
#define T75 75000
#define T100 100000
#define T125 125000
#define T150 150000
#define T175 175000
#define T200 200000
#include<stdio.h>
#include<stdlib.h>
#include <time.h>
#include "metodosOrdenacao.cpp"
int testaInsertion(int tam){
int v[tam], n=tam;
clock_t t;
geraVetor(v,n);
t = clock();
insertionSort(v,n);
t = clock() - t;
return t;
}
int testaSelection(int tam){
int v[tam], n=tam;
clock_t t;
geraVetor(v,n);
t = clock();
selectionSort(v,n);
t = clock() - t;
return t;
}
int testaBubble(int tam){
int v[tam], n=tam;
clock_t t;
geraVetor(v,n);
t = clock();
bubbleSort(v,n);
t = clock() - t;
return t;
}
int testaQuick(int tam){
int v[tam], n=tam;
clock_t t;
geraVetor(v,n);
t = clock();
quickSort(vet, 0, n -1);
t = clock() - t;
return t;
}
int testaMerge(int tam){
int v[tam], n=tam;
clock_t t;
geraVetor(v,n);
t = clock();
mergeSort( vet, n);
t = clock() - t;
return t;
}
int main(){
int i = T25;
printf("Bubble %.8f %d\n" , testaBubble(i),i);
printf("Insertion %.8f %d\n" , testaInsertion(i),i);
printf("Selection %.8f %d\n" , testaSelection(i),i);
printf("Merge %.8f %d\n" , testaMerge(i),i);
printf("Quick %.8f %d\n" , testaQuick(i),i);
}