代码来自码云
public static void shellSort(int[] arr){
int h = 1;
while(h < arr.length / 3){
h = h * 3 + 1;
}
while(h > 0){
int waitInsert;
int i,j;
for(i = h; i < arr.length; i++) {
waitInsert = arr[i];
j = i - h;
while(j > -1 && arr[j] >= waitInsert) {
arr[j + h] = arr[j];
j = j - h;
}
arr[j + h] = waitInsert;
}
h = (h - 1) / 3;
}
}
java希尔排序
原文:http://www.cnblogs.com/leirenyuan/p/7650197.html