Category : C Source Code
Archive   : CFUNS.ZIP
Filename : SSORT.C
* Shell sort modifed for determining intervals. Knuth pg 85.
*/
ssort(n,comp,swap)
unsigned n; /* number of records to sort */
int (*comp)(); /* pointer to function which compares two record keys
* and with K[i] compared to K[j], returns
* K[i] - K[j] (if K[i]>K[j] val>0, K[i]
int (*swap)(); /* pointer to function which swaps two records */
{
int m; /* interval indicator */
int i,j,k,l; /* internal counters */
m=n; /* initialize interval */
while(m/=2){ /* while an interval exists */
k=n-m; /* initialize i */
j=1; /* initialize j */
loop1:
i=j;
loop:
l=i+m;
if((*comp)(i-1,l-1)> 0){
(*swap)(i-1,l-1);
i=i-m;
if(i>=1)
goto loop;
}
if(++j>k)
continue;
goto loop1;
}
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/