Created
February 18, 2021 04:19
-
-
Save phc15/35bae3f63de991c1da2ad1229f45baea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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