快速排序的数值分析:有多少情况是坏情况?
A numerical analysis of Quicksort: How many cases are bad cases?
摘要:
我们提出了数值结果的概率为快速排序坏的情况下,即输入数据的排序成本大大超过平均值的情况下。动态规划用于计算比较的频率分布的递归的解决方案。从这些解决方案中,提取了相对于平均值高于特定阈值的比较次数的概率。计算的数组大小为n = 500个元素和几种方法来选择分区元素,从一个简单的随机选择,我们称之为“递归中位数的三个中位数。“我们发现,概率在很大程度上取决于选择方法:对于n = 500和比平均比较次数高25%的阈值,它的范围从2.2*10^(-3)到3.0*10^(-23)。提出了一种基于递归中位数的快速排序方法,我们的数据表明,最坏情况下的时间复杂度为O(n^1.37)。
英文摘要:
We present numerical results for the probability of bad cases for Quicksort, i.e. cases of input data for which the sorting cost considerably exceeds that of the average. Dynamic programming was used to compute solutions of the recurrence for the frequency distributions of comparisons. From these solutions, probabilities of numbers of comparisons above certain thresholds relative to the average were extracted. Computations were done for array sizes up to n = 500 elements and for several methods to select the partitioning element, from a simple random selection to what we call "recursive median of three medians." We found that the probability strongly depends on the selection method: for n = 500 and a theshold 25% above the average number of comparisons it ranges from 2.2*10^(-3) to 3.0*10^(-23). A version of Quicksort based on the recursive median of medians approach is proposed, for which our data suggest a worst case time complexity of O(n^1.37).
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。