希尔排序
package QFTest;
public class Test_09 {
public static void main(String[] args) {
int[] arrs={43,23,54,67,12,78,45,34,56,32,98,61};
shellSort(arrs);
for (int arr : arrs) {
System.out.print(arr+" ");
}
}
public static void shellSort(int[] arrs){
int pace=arrs.length;
while(true){
pace=pace/2;
for(int i=0;i<pace;i++){
for(int j=i+pace;j<arrs.length;j+=pace){
int temp=arrs[j];
int pos=j-pace;
while(pos>=0&&arrs[pos]>temp){
arrs[pos+pace]=arrs[pos];
pos-=pace;
}
arrs[pos+pace]=temp;
}
}
if(pace==1)
break;
}
}
}
12 23 32 34 43 45 54 56 61 67 78 98