[Shuo. Love Python] QuickSort (Quick Sort)

Source: Internet
Author: User
Tags shuffle

Def partition (a, i, j):     k = -1    while  True:        while k *  (A[i] - a[j])  >= 0:            if i ==  j:                  return i            j += k         a[i], a[j] = a[j], a[i]         i, j, k = j, i - k, -kdef qsort (a, i ,  j):     if i < j:        k  = partition (a, i, j)         qsort (A, i, &NBSP;K&NBSP;-&NBSP;1)          qsort (A, k + 1, j) Def quickSort (a):     qsort (A, 0, len (a)  - 1) if __name__ ==  ' __main__ ':     from random import shuffle    data = range (100)     shuffle (data)     print  ' before:\n ', data     quicksort (data)     print  ' after:\n ',  data

Liu Shuo teacher python fine course:

" Python advanced Programming Skills Combat":

" python algorithm Combat video Course":

" Python scientific Computing-numpy Combat Course": < Strong style= "padding:0px;margin:0px;" >

panda tv Live room:

http://www.panda.tv/671023


[Shuo. Love Python] QuickSort (Quick Sort)

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.