Quicksort Is Optimal For Many Equal Keys
نویسنده
چکیده
I prove that the average number of comparisons for median-of-k Quicksort (with fat-pivot a.k.a. three-way partitioning) is asymptotically only a constant αk times worse than the lower bound for sorting random multisets with Ω(nε) duplicates of each value (for any ε > 0). The constant is αk = ln(2)/ ( Hk+1 −H(k+1)/2 ) , which converges to 1 as k →∞, so Quicksort is asymptotically optimal for inputs with many duplicates. This resolves a conjecture by Sedgewick and Bentley [37, 38] and constitutes the first progress on the analysis of Quicksort with equal elements since Sedgewick’s 1977 article.
منابع مشابه
Partitioning schemes for quicksort and quickselect
We introduce several modifications of the partitioning schemes used in Hoare’s quicksort and quickselect algorithms, including ternary schemes which identify keys less or greater than the pivot. We give estimates for the numbers of swaps made by each scheme. Our computational experiments indicate that ternary schemes allow quickselect to identify all keys equal to the selected key at little add...
متن کاملA Cost Optimal Parallel Quicksort on CREW PRAM
In this paper we introduce a cost optimal parallel quicksort algorithm. It sorts an array of n elements in O(log n) time using O( n n log ) processors on a CREW PRAM. That is, the total cost is O(n log n), the same as an average sequential quicksort algorithm. The key feature of the proposed algorithm is that it partitions the array concurrently. This removes the performance bottleneck proposed...
متن کامل0055 Large Deviations for Quicksort ∗
Let Qn be the random number of comparisons made by quicksort in sorting n distinct keys, when we assume that all n! possible orderings are equally likely. Known results concerning moments for Qn do not show how rare it is for Qn to make large deviations from its mean. Here we give a good approximation to the probability of such a large deviation, and find that this probability is quite small. A...
متن کاملA note on multipivot Quicksort
We analyse a generalisation of the Quicksort algorithm, where k uniformly at random chosen pivots are used for partitioning an array of n distinct keys. Specifically, the expected cost of this scheme is obtained, under the assumption of linearity of the cost needed for the partition process. The integration constants of the expected cost are computed using Vandermonde matrices.
متن کاملQuicksort Algorithm Again Revisited
We consider the standard Quicksort algorithm that sorts n distinct keys with all possible n! orderings of keys being equally likely. Equivalently, we analyze the total path length n in a randomly built binary search tree. Obtaining the limiting distribution of n is still an outstanding open problem. In this paper, we establish an integral equation for the probability density of the number of co...
متن کامل