Data Structure-Sort ----- insert sort

Source: Internet
Author: User

Insert sorting refers to inserting elements into an array that has been sorted,

For example, {2, 3, 5} is an array composed of the five elements. Now we want to sort them. First, we think of {2} As an array that has been sorted. Then, insert the 3 element into the sorted {2} array, so {2, 3} will exist, and then insert 1 to the sorted Array {2, 3, at this time, the element 1 is compared with each element in the sorted array until the position of the element is found.

And so on;

Paste the code below: (full copy, you can run it) here the VC ++ 6.0 compiling environment is used, and the C language is used;

 

Data Structure-Sort ----- insert sort

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.