Basic Sorting Algorithm -- select sorting java Implementation

Source: Internet
Author: User

There is a great similarities between sorting and Bubble sorting. The final position of an element can be determined after a traversal. The main idea is to select the smallest element and the first element for one traversal, in this way, the elements are ordered, and then the second small element is selected to exchange with the second element. Knowing that there is only one element left, the largest element is displayed. At this time, the sorting is complete.

The Code is as follows; eclipse 4.3 jdk1.6

<AnyType Comparable <? AnyType> minIndex = 0 (a =) | (. length = 0 (I = 0; I <. length; I ++ minIndex = I; (j = I + 1; j <. length; j ++) {(a [j]. compareTo (a [minIndex]) <0 minIndex = (minIndex! = I) {temp = a [I] = a [minIndex] = Random rand = Integer [] arr = Integer [10 (I = 0; I <10; I ++ arr [I] = rand. nextInt (1000}

J. Continue to work

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.