Fast sequencing is a sort of algorithm developed by Donny Holl. On average, sort n items to 0 (n log n) comparisons. In the worst case scenario, a 0 (N2) comparison is required, but this is not a common situation. In fact, fast sequencing is usually much faster than the other 0 (n log n) algorithms because its internal loop (inner Loop) can be implemented efficiently on most architectures
Quick Sort Core:"datum" (pivot), partition (partition), swap (swap), recursive (recursive).
Quick Sort Implementation:
/* *AUTHOR:BOOIRROR (AT) 163 (dot) com *date:2015/4/28 */#include <stdio.h>void swap (int a[], int n, int m) {if (n = = m ) Return;int tmp = a[n];a[n] = a[m];a[m] = tmp;} void qsort (int a[], int n) {int I, j;int last = 0;if (n < 2) Return;swap (A, 0, N/2); for (i = 1; i < n; i++) {if (A[i] < a[0]) {swap (A, ++last, i);}} Swap (A, 0, last): Qsort (A, last); Qsort (a+last+1, n-last-1);} int main () {int i = 0; int ra[10] = {n , 1,----------------- Qsort (RA, ten); while (I <) printf ("%d", ra[i++]); Puts ("\ n"); int ar[6] = {4, 6, one, one, one, one, 41};qsort (AR,); for (i=0; i < 6; i++) {printf ("%d", Ar[i]);} Puts ("\ n"); return 0;}
Quick-Sort Process animations:
Finish
Seconds to understand quick sort