Sort algorithm Getting started with the Hill sort (Java implementation)

Source: Internet
Author: User

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, 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)





Sort algorithm Getting started with the Hill sort (Java implementation)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.