I have this code working properly.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void quicksort (int *vetor, int inicio, int fim) {
int i, j, meio, aux;
i = inicio;
j = fim;
meio = vetor [(inicio+fim)/2];
do {
while (vetor [i] < meio)
i++;
while (vetor [j] > meio)
j--;
if (i<= j) {
aux = vetor[i];
vetor[i] = vetor[j];
vetor[j] = aux;
i++;
j--;
}
} while (i <= j);
if (inicio < j)
quicksort(vetor, inicio, j);
if (i < fim)
quicksort(vetor, i, fim);
}
int main()
{
int vetor[8] = {25, 57, 48, 37, 12, 92, 86, 33};
int n = 8, i;
quicksort(vetor,0,n-1);
for (i=0; i<8; i++) {
printf("%d ", vetor[i]);
}
return 0;
}
1 - I determine the middle of the vector and this medium will be the pivot, which in my accounts is in position 3, content 37.
From here on, what's the next step?