Python Learning Second Order

Source: Internet
Author: User

#排序 Programming World Game Rules # values found according to the index # value can be swapped for size # value can be exchanged position # bubble sort # In contrast, if an element is larger than the right, swap position Arr=[3,4,8,9,10,6,5,7]length=len (arr) for I In range (length-1):p rint ' * ' *20print IFOR J in Range (length-i-1): If arr[j]>arr[j+1]: arr[j],arr[j+1]=arr[j+1],arr[j ] print ' list is%s '% (arr) Print arr
#coding =utf-8# Insert Sort # Insert Sort (insertion sort) The algorithm description is a simple and intuitive sorting algorithm. It works by constructing an ordered sequence, for unsorted data, from a backward forward scan in a sorted sequence, to find the appropriate location and insert an array = [3,1,4,2,5,7,6]length = Len (array) for I in Range (length-1): for J in Range (I+1,length): If ARRAY[I]>ARRAY[J]: Array[i],array[j]=array[j],array[i]print array


This article from "Do not abandon!" Do not give up "blog, declined reprint!"

Python Learning Second Order

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.