Sorting algorithms/Shell sort: Difference between revisions

m
(commo lisp shell sort)
Line 141:
int main (int argc, char *argv[])
{
int intArray[ARRAYSIZE], i, increment;
 
for(i=0; i<=ARRAYSIZE-1; i++)
intArray[i] = rand();
shellsort(intArray, ARRAYSIZE);
}
 
void shellsort (int a[], int length)
{
int i, j, k, temp, increment;
static int incSequence[] = {412771, 165103, 66041, 26417, 10567,
4231, 1693, 673, 269, 107, 43, 17, 7, 3, 1};
 
Line 157:
{
if (incSequence[k]*2 > length) continue;
increment = incSequence[k];
for (i=increment; i < length; i++)
{
Line 168:
a[j + increment] = temp;
}
}
}</lang>