Code Id | 33 | |
---|---|---|
Date Updated | 3/7/2010 | |
Title | Shell sor | |
Description | ||
This program implements shell sort. Shell sort is named after its discoverer D.L. Shell. It is also called diminishing-increment sort. Here we first compare the keys that are far apart. Afterwards, we sort the entries which are closer together. |
||
Codes Snippet | ||
shellsort( int a[], int n, int inc[], int ninc) { int i, j, k, increment, x; i = 0; while ( i < ninc ) { increment = inc [i]; j = increment; while (j < n) { /* insert a[j] into its proper place within its subfile */ x = a[j]; for (k=j � increment; k>=0 && x > a[k]; k �= increment) a[k + increment] = a[k]; a[k + increment] = x; j ++; }/*end of inner while*/ i++; }/*end of outer while*/ }/*end of routine*/ |
Online Enquiry
Course Registration
-
Recent Posts