#include <iostream>
#include "0-pruebas.h"
using namespace std;
void quicksort(int a[], int low, int high){
if (low<high){
//particionar desde a[low] hasta a[high]
//y devolver el indice del pivote
int pivotIdx=partition(a,low,high);
//recursivamente ordenar las dos partes
quicksort(a,low,pivotIdx-1);
quicksort(a,pivotIdx+1,high);
}
}
int partition(int a[], int i, int j){
int p=a[i]; // p es el pivote
// Las sublistas S1, S2,
// estan vacias al inicio
int m = i;
// pasamos por cada elemento en la
// region no particionada
for (int k=i+1; k<=j; k++){
if (a[k]<p)
{
m++;
swap(a[k],a[m]);
}
else{
// no se hace nada
}
}
// intercambiar el pivote con a[m]
swap(a[i],a[m]);
//retornamos el indice del pivote
return m;
}