import java.util.Arrays;
public class ShellSort {
public static void main(String[] args) {
int[] array = { 1, 4, 3, 6, 5, 8, 9, 2, 7, 0 };
ShellSort.shellSort(array);
;
}
private static void shellSort(int[] array) {
int d = array.length;
while (true) {
d = d / 2;
for (int x = 0; x < d; x++) {
for (int i = x + d; i < array.length; i = i + d) {
int temp = array[i];
int j;
for (j = i - d; j >= 0 && array[j] > temp; j = j - d) {
array[j + d] = array[j];
}
array[j + d] = temp;
}
}
if (d == 1) {
break;
}
}
System.out.println(Arrays.toString(array));
}
}
11-18