python 快速排序
平均时间复杂度O(nlogn)
最坏情况O(n^2)
def quick(array): if len(array)<2: return array else: pivot_index = 0 pivot = array[pivot_index] less_part = [i for i in array[pivot_index+1:]if i <pivot ] great_part = [i for i in array[pivot_index+1:]if i>pivot] return quick(less_part) + [pivot]+quick(great_part) a = [7,24,3,12,44,6] print(quick(a))