Binary insertion sort (binary insertion sort) is an improvement to the insert sort algorithm, because in the process of sorting algorithms, the elements are constantly inserted into the ordered sequence. Since the first half is a sorted sequence, so that we don't have to search for the insertion point sequentially, we can use the binary lookup method to speed up the search for the insertion point.
public static void Halfsort (int[] array) {
int low, high, mid;
int tmp, J;
for (int i = 1; i < Array.Length i++) {
tmp = array[i];
Low = 0;
High = i-1;
While [low <= high] {
mid = low + (high-low)/2;
if (Array[mid] > tmp) high
= Mid-1;
else low
= mid + 1;
}
for (j = i-1, J > high; j--) {
array[j + 1] = Array[j];
}
Array[high + 1] = tmp;
}
}
Binary sorting algorithm diagram:
The above mentioned is the entire content of this article, I hope to be able to learn Java binary sorting algorithm help.