Skip to content

Instantly share code, notes, and snippets.

@phc15
Created February 18, 2021 04:19
Show Gist options
  • Save phc15/35bae3f63de991c1da2ad1229f45baea to your computer and use it in GitHub Desktop.
Save phc15/35bae3f63de991c1da2ad1229f45baea to your computer and use it in GitHub Desktop.
public class ShellSort {
static int gap, i, j, temp;
static void sort(int[] v, int n) {
for (gap = n / 2; gap > 0; gap /= 2) {
for (i = gap; i < n; i++) {
for (j = i - gap; j >= 0 && v[i] < v[j]; j -= gap) {
temp = v[j];
v[j] = v[j + gap];
v[j + gap] = temp;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment