Three sort algorithms (bubble/quick/Shell) bubble, fast sort, Hill ......

Source: Internet
Author: User

Preparing for Job Review in the last two days. This section summarizes the three sorting algorithms mentioned in the internal sorting chapter of the data structure. Simple implementation.

// Sort. CPP: defines the entry point for the console application. // # include "stdafx. H "# include <stdio. h> void bubble (INT list [], int N) {int I, j, temp; for (I = 0; I <n; I ++) {for (j = 0; j <n-i-1; j ++) {If (list [J]> list [J + 1]) {temp = list [J]; list [J] = list [J + 1]; list [J + 1] = temp ;}}}} //************************************** ********** // Hill sorting //*********************** ************************* void shellinsert (INT list [], int DK, int Len) {int I, j; int temp; for (I = dk; I <Len; ++ I) {If (list [I] <list [I-dk]) {temp = list [I]; for (j = I-DK; j> = 0 & (temp <list [J]); j-= dk) {list [J + dk] = list [J];} list [J + dk] = temp ;}} void shellsort (INT list [], int Len) {int Dk = Len; while (DK> 0) {Dk = Dk/2; shellinsert (list, DK, Len );}} //************************************** ******************* // quick sorting //************** **************************************** * *** int partition (INT list [], int low, int high) {int lower tkey; lower tkey = list [low]; while (low 

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.