Skip to content

Instantly share code, notes, and snippets.

@metallurgix
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save metallurgix/36d19bafdc2f933e7f2a to your computer and use it in GitHub Desktop.

Select an option

Save metallurgix/36d19bafdc2f933e7f2a to your computer and use it in GitHub Desktop.
Shell Sort
void shellsort(int *a, int n)
{
int h, i, j, k;
for (h = n; h /= 2;)
{
for (i = h; i < n; i++)
{
k = a[i];
for (j = i; j >= h && k < a[j - h]; j -= h) {
a[j] = a[j - h];
}
a[j] = k;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment