The hill sort is an improvement on the insertion sort. The insertion sort is the first element in order, the moving element moves backwards one at a time, and when the inserted element is less than the order of all the elements in front of it, you need to move all the preceding elements backwards. The hill sort has its own increment, which can be understood as the increment for the insertion sort is 1, and the hill sort increment is gap. The code is a loop that increments the incremental change based on the insertion of the sort code. can refer to http://www.cnblogs.com/chengxiao/p/6104371.html, Bo Master made a detailed introduction.
public static void Shellsort (int[] a) {
Int J;
for (int gap=a.length/2;gap>0;gap/=2)
for (int i=gap;i<a.length;i++) {
int tmp=a[i];
for (J=I;J>=GAP&&TMP<A[J-GAP];J-=GAP)
A[J]=A[J-GAP];
a[j]=tmp;
}
}
Sort algorithm Getting started with the Hill sort (Java implementation)