The fast sorting algorithm is the worst of the complexity, the equivalent of the insertion sort, but the average performance is good, and even most of the time is better than the heap sort and merge sort, and is an internal sorting algorithm, so in practice often use the most.
Quick Sort steps: Divide the array A[P...R] into two sub-arrays a[p...q-1] and A[Q+1...R] so that each element of the former is less than or equal to a[q], and each element of the latter is greater than or equal to a[q]. Then recursively call the function, the two sub-arrays to quickly sort.
#include <stdio.h>void quicksort (int *a,int p,int r), int partition (int *a,int p,int R), main () {int a[12] = {2,8,23,7, 1,3,5,34,64,6,32,4};int i;//printf ("%d\n", Partition (a,1,8)), quicksort (a,1,12); for (i = 0;i < 12;i++) printf ("%d ", A[i]);p rintf (" \ n ");} void quicksort (int *a,int p,int r) {int q;//,partition (int *a,int p,int R), if (P < r) {q = partition (a,p,r); Quicksort (A, P,Q-1); quicksort (a,q+1,r);}} int partition (int *a,int p,int r) {int X,i,j;int temp;x = A[r-1];i = P-1;for (j = p-1;j < r-1;j++) {if (A[j] <= x) {temp = A[i];a[i] = a[j];a[j] = temp;i++;}} temp = A[i];a[i] = a[r-1];a[r-1] = temp; return i+1;}
Fast sorting and C language implementation