public class BinaryInsertionSort {
public static void binarySort(int[] array)
{
int Row=array.length;
for(int I=1;I<Row;I++)
{
int temp=array[I];
int V=I-1;
int low=0;
int high=V;
int mid=0;
while(low<=high)
{
mid=(low+high)/2;
if(array[mid]<=temp)
low=mid+1;
else
high=mid-1;
}
for(int j=V;j>=mid;j--)
{
array[j+1]=array[j];
}
array[low]=temp;
}
}
|
|