快速排序基于分治法。此算法的平均时间复杂度为 O(n*log(n)),但最坏情况下的复杂度为 O(n^2)。为了减少最坏情况发生的可能性,这里使用随机化实现了快速排序。算法partition(int a[], int l, int h)开始 pivot = h Index = l start = l 且 end = h 当 start < end 时执行 当 a[start] pivot 时执行 end = end – 1 完成 如果 start < end 则 交换 a[start] 与 a[end] ... 阅读更多