JavaScript, "Insert Sort" of python,go,java,c# Series algorithm

Source: Internet
Author: User


the common internal sorting algorithms are: Insert Sort, hill sort, select sort, bubble sort, merge sort, quick sort, heap sort, cardinality sort and so on. Summarize with a picture:


650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/95/53/wKioL1kUE5LRymxfAAHcPIbdiTU968.png-wh_500x0-wm_ 3-wmp_4-s_2575929143.png "title=" 21.png "alt=" Wkiol1kue5lrymxfaahcpibditu968.png-wh_50 "/>


Insert Sort

Insert Sort (English: Insertion sort) is a simple and intuitive sorting algorithm. It works by constructing an ordered sequence, for unsorted data, to scan from backward forward in the sorted sequence, to find the appropriate position and insert it. The insertion sort is implemented on an implementation, usually in the order of In-place (that is, the ordering of extra space using only O (1), so that in the backward-forward scanning process, the ordered elements need to be moved back and forth gradually, providing the insertion space for the newest elements.


Insert sort and bubble sort, there is also an optimization algorithm called split-half insertion.


2. Algorithm steps


    • The first element of the first order sequence is treated as an ordered sequence, and the second element to the last element as an unordered sequence.


    • Scans the unordered sequence from beginning to end, inserting each element scanned into the appropriate position of the ordered sequence. (If the element you want to insert is equal to an element in an ordered sequence, insert the element you want to insert behind the equal element.) )



2. Dynamic Diagram Demonstration



650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/95/53/wKioL1kUE-yg1vmQAAAyfu8sQrk333.png-wh_500x0-wm_ 3-wmp_4-s_818173473.png "title=" 22.png "alt=" Wkiol1kue-yg1vmqaaayfu8sqrk333.png-wh_50 "/>


650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/95/53/wKioL1kUFCngkJQsAAA_8gbsMB4846.png-wh_500x0-wm_ 3-wmp_4-s_373814632.png "title=" 23.png "alt=" Wkiol1kufcngkjqsaaa_8gbsmb4846.png-wh_50 "/>







3. JavaScript Code Implementation



650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/95/54/wKiom1kUFtaxLWK4AABMWQ9-Cpc756.png-wh_500x0-wm_ 3-wmp_4-s_4012934884.png "title=" 31.png "alt=" Wkiom1kuftaxlwk4aabmwq9-cpc756.png-wh_50 "/>



4. Python Code Implementation



650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/95/54/wKiom1kUFwaTEyGmAAA1zIH5R7I570.png-wh_500x0-wm_ 3-wmp_4-s_2937197305.png "title=" 32.png "alt=" Wkiom1kufwateygmaaa1zih5r7i570.png-wh_50 "/>


5. Go Code Implementation


650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/95/54/wKioL1kUF0GB7xvsAAA6XY1UZas038.png-wh_500x0-wm_ 3-wmp_4-s_985027382.png "title=" 33.png "alt=" Wkiol1kuf0gb7xvsaaa6xy1uzas038.png-wh_50 "/>




6. Java implementation



650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/95/54/wKiom1kUF3aADlruAAA-sn_eq0U553.png-wh_500x0-wm_ 3-wmp_4-s_70738832.png "title=" 34.png "alt=" Wkiom1kuf3aadlruaaa-sn_eq0u553.png-wh_50 "/>



7 another version of Java



650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/95/54/wKioL1kUF6vzYY9DAABaxtwMb4M357.png-wh_500x0-wm_ 3-wmp_4-s_3295185985.png "title=" 36.png "alt=" Wkiol1kuf6vzyy9daabaxtwmb4m357.png-wh_50 "/>


8. C # Implementation



650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/95/54/wKioL1kUF-qRpDkSAAA2ptRw6nk285.png-wh_500x0-wm_ 3-wmp_4-s_163974096.png "title=" 37.png "alt=" Wkiol1kuf-qrpdksaaa2ptrw6nk285.png-wh_50 "/>



far awayFront-end and Golang backend microservices development, architecture, and team focus on front end, client, and concurrency response. Now employed in foreign companies, technical director, Micro-service architecture. Often active in Learn the front-end direction from scratch, large front-end technology,Full stack technology Group,Ionic2 Hybrid app development and other groups inside to do some sharing, hope that through their own influence so that the people around to feel more of the industry's residual temperature, willing to help those who need to solve the technical problems of the crowd.Please contact:Sen0676  qq invite to group : 525331804   All-Stack QQ group : 581993430


Recently I will teach you how to learn programming skills yourself, how to write a good resume, to find the job you want. The dream starts here. Combined with my own study of the front-end to find work experience, how to learn, modular system. I will share my own how to learn the front-end, how to improve the development efficiency in practice, standardize the development process.

    • 1, the front-end self-study and improve

    • 2, the production and delivery of resumes

    • 3. The skills that should be mastered in front-end interview work

    • 4, front-end interview some problems set

    • 5, the enterprise needs the front-end recruitment of talent, etc.

This article is from the "Technology-aware" blog, so be sure to keep this source http://liuzhiying.blog.51cto.com/5850988/1924582

JavaScript, "Insert Sort" of python,go,java,c# Series algorithm

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.