python实现快速排序算法

很多基础的算法只看不写很容易忽略其中的细节,对于既不浪费空间又可以快一点的快速排序算法,用python重新实现了一遍,下面具体的实现方法,仅供参考。

def quicksort(left,right):
    if left>right:
        return
    temp=a[left]

    i=left
    j=right
    while i!=j:
        while a[j]>=temp and i1
            print(a[j])
        while a[i]<=temp and i1
        if ia[i]
            a[i]=a[j]
            a[j]=t
    a[left]=a[i]
    a[i]=temp
    quicksort(left,i-1)
    quicksort(i+1,right)

你可能感兴趣的:(Python,算法)