Skip to content
Snippets Groups Projects
Commit f60f8146 authored by Fernando Erd's avatar Fernando Erd :ok_hand:
Browse files

Quick analisa o tempo agr

parent 3057da1e
Branches
No related tags found
No related merge requests found
No preview for this file type
......@@ -29,6 +29,34 @@ void TempoBubbleSort (int *Vetor) {
printf ("O BubbleSort Demorou %d Centesimos\n", tmili);
}
void TempoQuickSortRecursivo (int *Vetor) {
struct timeval inicio, final;
int tmili, i;
gettimeofday(&inicio, NULL);
for (i = 0; i < 10000; i ++) {
GeraVetor(Vetor);
QuickSortRecursivo (Vetor, 0, TAM);
}
gettimeofday(&final, NULL);
tmili = (int) (1000 * (final.tv_sec - inicio.tv_sec) + (final.tv_usec - inicio.tv_usec) / 1000);
printf ("O QuickSort Recursivo Demorou %d Centesimos\n", tmili);
}
void TempoQuickSortIterativo (int *Vetor) {
struct timeval inicio, final;
int tmili, i;
gettimeofday(&inicio, NULL);
for (i = 0; i < 10000; i ++) {
GeraVetor(Vetor);
QuickSortIterativo (Vetor, 0, TAM);
}
gettimeofday(&final, NULL);
tmili = (int) (1000 * (final.tv_sec - inicio.tv_sec) + (final.tv_usec - inicio.tv_usec) / 1000);
printf ("O QuickSort Iterativo Demorou %d Centesimos\n", tmili);
}
int main () {
int Vetor[TAM], Escolhidos[4];
int comando;
......@@ -46,5 +74,7 @@ int main () {
case 2:
TempoSelectSort (Vetor);
TempoBubbleSort (Vetor);
TempoQuickSortRecursivo (Vetor);
TempoQuickSortIterativo (Vetor);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment