The basic idea of Hill sort algorithm is to take an integer D1 less than n as the first increment, and divide all the records into D1 groups. All records that are multiples of the DL are placed in the same group. First in each group of direct interpolation sort; Then, take the second increment d2<d1 repeat the grouping and sorting above until the incremental dt=1 (DT<DT-L<...<D2<D1) is taken, that is, all records are placed in the same group for direct insertion sort. The method is essentially a grouping insertion method.
Insert sort with increments public
static void Shellsort (int[] array) {
int len = array.length;
int h = 1;
while (H < len)
h = h * 3 + 1;
while (H >= 1) {for
(int i = 1; i < Len; i++) {for
(int j = i; J >= h; j = j-h) {
if (array[j) &L T Array[j-h]) {
Sort.swap (array, J, j-h);//Swap J and J-h
} else break
;
}
h = H/3;
}
}
Hill Sort Sketch
The above is the entire content of this article, I hope to be proficient in the Java Hill sort of help.