def quick_sort(lst):
def qsort(lst,begin,end):
if begin >= end:
return
pivot = lst[begin]
i = begin
for j in range(begin+1,end+1):
if lst[j] < pivot:
i+=1
lst[i],lst[j] = lst[j],lst[i]
lst[begin],lst[i] = lst[i],lst[begin]
qsort(lst,begin,i-1)
qsort(lst,i+1,end)
qsort(lst,begin,end)
python数据结构4: 快速排序
猜你喜欢
转载自blog.csdn.net/weixin_38246633/article/details/80685887
今日推荐
周排行