1 /* Weiss used 1-n as the indices of the array rather than 0 to n-1 Also, he
\r
2 modified the Ada version quite a bit so that it would "work" in C. In the Ada
\r
3 version he used "and then" to force what is called short- circuit evaluation.
\r
4 All C comparisons use short-circuit evaluation so the algorithm did NOT need to
\r
9 void shellsort(int a[], int n)
\r
11 int i, j, increment;
\r
14 for (increment = n/2; increment > 0; increment /= 2)
\r
16 for (i = increment; i < n; i++) /*changed this line*/
\r
20 while ((j>=increment)&&(temp<a[j-increment]))
\r
22 a[j] = a[j-increment];
\r
30 void print(int a[], int high)
\r
33 for (i = 0; i < high; i++)
\r
41 int array[13]={81, 94, 11, 96, 12, 35, 17, 95, 28, 58, 41, 75, 15};
\r
43 shellsort(array, 13);
\r