Topic: Shell Sort


Author: mtichy@fraser.sfu.ca (Martin Tichy)
Date: Mon, 16 Nov 1992 07:19:37 GMT
Raw View
Can anyone please post or mail me a C++ shell sort?  I can't
seem to get this one to work.

void shell_sort (int list[], int size)
{
int i, j, gap;

for ( gap = size / 2; gap > 0; gap /= 2)
  for (i = gap; i < size; i++)
    for (j = i - gap; j >= 0; j -= gap)
      if (list [i] <= list [i+1]
        break;
swap ( &list [j], &list [j+1] );
}