package test;
/*
先分组排序提升整体有序性 最后进行插入排序
*/
public class shellSort {
public static void insertSort(int[] arr,int sper) {
ArrCreater.printArr(arr);
for (int i = sper; i < arr.length; i+=sper) {
for (int j = i; j > 0; j-=sper) {
if (arr[j] > arr[j - sper]) {
break;
} else {
int temp = arr[j];
arr[j] = arr[j - sper];
arr[j - sper] = temp;
}
}
ArrCreater.printArr(arr);
}
ArrCreater.printArr(arr);
}
public static void main(String args[]) {
//insertSort(ArrCreater.create(10),1);
int nmb=20;
int[] arr=ArrCreater.create(nmb);
while(nmb/2>=1) {
insertSort(arr,nmb/2);
nmb=nmb/2;
}
}
}