Pseudo Code Pseudocode

Source: Internet
Author: User

Insert Sort

1insertion-SORT (A)2  forj←2To Length (A)3      DoKey←a[j]4? Insert A[j] into the sorted sequence a[1.. J-1]5i←j-16          whileI>0and a[i]>Key7              Doa[i+1]←a[i]8i←i-19a[i+1]←key

Merge sort

1 MERGE (a,p,q,r)2n1←q-p+13n2←r-Q4Create Arrays L[1.. n1+1] and r[1.. n2+1]5  fori←1to N16      Dol[i]←a[p+i-1]7  forj←1To N28      Dor[j]←a[q+J]9l[n1+1]←∞Tenr[n2+1]←∞ Onei←1 Aj←1 -  forK←p to R -      Do ifl[i]<=R[j] the Then A[k]←l[i] -i←i+1 -         ElseA[k]←r[j] -j←j+1 +  -merge-SORT (a,p,r) + ifp<R AThen Q←floor ((p+r)/2) atmerge-SORT (a,p,q) -Merge-sort (a,q+1, R) -MERGE (A,p,q,r)

Bubble sort

1 bubble-SORT (A)2 for i←1 to Length[a]3do        for J←length[a] downto i+14do         if a[j]<a[j-1  ]5then             exchange a[j]←→a[j-1]

Pseudo Code Pseudocode

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.