作业部落:https://www.zybuluo.com/listenviolet/note/1399285
以上链接是自己在作业部落编辑的排序算法总结~
Github: https://github.com/listenviolet/py_code/tree/master/sort
Github中有对这10种排序算法的Python代码总结~
IntorSort
在C++中的sort()函数中使用的是IntroSort算法。IntroSort是QuickSort, HeapSort, Insertion Sort的混合版本,通过三者的组合来达到最小化运算时间的效果。
那么这三个算法是如何协调工作的呢?
https://www.geeksforgeeks.org/know-your-sorting-algorithm-set-2-introsort-cs-sorting-weapon/
1. IntorSort首先采用QuickSort, 如果QuickSort的递归深度超过规定的限制$2log(N)$,就会转用HeapSort,以避免出现$O(N^2)$的QuickSort的最差时间复杂度。
2. 如果QuickSortpartition size中的排序元素的个数非常少时(设置为小于16时),会采用InsertSort.
3. 如果partition size 在 [16, 2*log(N)] 之间时,使用QuickSort.