- 希尔排序是插入排序的加强版
public static void main(String[] args) {
int[] arr = {9,7,5,76,45,12,44,65,78};
for (int D = arr.length/2; D >0 ; D/=2) {
for (int i = D; i <arr.length ; i+=D) {
int insert = arr[i];
int index = i-D;
while (index>=0&&insert<arr[index]){
arr[index+D] = arr[index];
index -= D;
}
arr[index+D] = insert;
}
}
System.out.println(Arrays.toString(arr));
}