对典型QuickSort进行以下哪些更改平均可以提高其性能,通常在实践中进行。
1) Randomly picking up to make worst case less
likely to occur.
2) Calling insertion sort for small sized arrays
to reduce recursive calls.
3) QuickSort is tail recursive, so tail call
optimizations can be done.
4) A linear time median searching algorithm is used
to pick the median, so that the worst case time
reduces to O(nLogn)
(A) 1和2
(B) 2、3和4
(C) 1、2和3
(D) 2、3和4答案: (C)
说明:通常不使用第四优化,它可以将最坏情况下的时间复杂度降低到O(nLogn),但是隐藏常数非常高。
这个问题的测验