Java data structure and algorithm insertion algorithm implementation numerical ordering example _java

Source: Internet
Author: User

This article describes the Java data structure and algorithm of the insertion algorithm to achieve numerical ordering. Share to everyone for your reference, specific as follows:

Write here to do a souvenir, the key is to understand the insertion point, at the insertion point, the initial in and out are at this insertion point, and then through in self minus the array to reorder

public static void Insertsort () {for
  (int out=1; out<a.length; out++) {
    int temp = a[out];
    int in = out;
    while (in>0&& a[in-1]>temp) {
      a[in] = a[in-1];
      --in;
    }
    A[in] = temp;
  }
}

More about Java algorithms Interested readers can view the site topics: "Java data structure and algorithms tutorial", "Java Operation DOM node skills summary", "Java file and directory operation tips Summary" and "Java Cache operation Tips"

I hope this article will help you with Java programming.

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: info-contact@alibabacloud.com 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.