# (10) select one sort and simply select sort

Source: Internet
Author: User

Simple selection and sorting(Simple
Selection sort). The simple selection and sorting operation is to select the records with the smallest keyword from n-I + 1 records through the comparison between n-I keywords, and exchanged with the I (1 <= I <= N) records. Time Complexity:O (N ^ 2).

` //  Simple selection and sorting    Void  Cselectionsort: simpleselectionsort (  Void  ){  Const     Int  Count  =    9  ;  Int  L [count]  =  {  0  ,  49  ,  38  ,  65  ,  97  ,  76  , 13  ,  27  ,  49  };  For  (  Int  I  =     0  ; I  <  Count;  ++  I){ Int  J  =  Selectminkey (L, Count, I );  If  (I  ! =  J){  Int  Temp  =  L [I];L [I]  =  L [J];L [J]  =  Temp;}} //  Print the sorting result.      For  (  Int  I  =     0  ; I  <  Count;  ++  I){Cout  < L [I]  <     "  \ T  "  ;}Cout  <  Endl;}  //  Simple selection and sorting of minimum values    Int  Cselectionsort: selectminkey (  Int  L [], Int  Count,  Int  I){  Int  Index  =  I;  For  (  Int  J  =  I  +     1  ; J <  Count; j  ++  ){  If  (L [J]  <  L [Index])Index  =  J;}  Return  Index;} `

Simple sorting is to select the element index with the minimum key value in the sequence to be sorted. Then it is exchanged with the first element of the sequence to be sorted. In Bubble sorting, two adjacent elements are exchanged in reverse order.

Related Keywords:

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.