/**
* @author Think
*折半插入排序
*/
public class binInsertSort {
private static int a[]={22,3,43,11,99,88,34,34,33,22,11,1};public static void main(String[] args) {int []b=binInsertSort(a,0,12);for(int i=0;i<b.length;i++){System.out.print(a[i]+"\t");}
}public static int[] binInsertSort(int[] a,int low,int high){for(int i=low+1;i<a.length;i++){//保存插入元素int temp=a[i];//设置初始区间 int hi=i-1;int lo=low;//折半决定插入位置while(lo<=hi){int mid=(hi+lo)/2;if(temp<a[mid]){hi=mid-1; }else{lo=mid+1;}}//移动在temp那个之后的元素for(int j=i-1;j>hi;j--)a[j+1]=a[j];//插入元素tempa[hi+1]=temp;}return a;}
/**