Quicksort is an elegant and efficient sorting algorithm. Analysis of quick sort is a lot of fun. The core part of quick sort algorithm is partition the original array into two parts. This part of code is shown below (in java):
private void quicksort(int[] a, int lo, int hi) {
if (hi <= lo) return;
int i = lo - 1, j = hi;
int t, v = a[hi];
while (true) {
while (a[++i] < v);
while (v < a[--j])
if (j == lo) break;
if (i >= j) break;
t = a[i]; a[i] = a[j]; a[j] = t;
}
t = a[i];
a[i] = a[hi];
a[hi] = t;
quicksort(a, lo, i - 1);
quicksort(a, i + 1, hi);
}
