12 research outputs found

    Worst-Case Efficient Sorting with QuickMergesort

    Full text link
    The two most prominent solutions for the sorting problem are Quicksort and Mergesort. While Quicksort is very fast on average, Mergesort additionally gives worst-case guarantees, but needs extra space for a linear number of elements. Worst-case efficient in-place sorting, however, remains a challenge: the standard solution, Heapsort, suffers from a bad cache behavior and is also not overly fast for in-cache instances. In this work we present median-of-medians QuickMergesort (MoMQuickMergesort), a new variant of QuickMergesort, which combines Quicksort with Mergesort allowing the latter to be implemented in place. Our new variant applies the median-of-medians algorithm for selecting pivots in order to circumvent the quadratic worst case. Indeed, we show that it uses at most nlogn+1.6nn \log n + 1.6n comparisons for nn large enough. We experimentally confirm the theoretical estimates and show that the new algorithm outperforms Heapsort by far and is only around 10% slower than Introsort (std::sort implementation of stdlibc++), which has a rather poor guarantee for the worst case. We also simulate the worst case, which is only around 10% slower than the average case. In particular, the new algorithm is a natural candidate to replace Heapsort as a worst-case stopper in Introsort

    QuickXsort: Efficient Sorting with n log n - 1.399n +o(n) Comparisons on Average

    Full text link
    In this paper we generalize the idea of QuickHeapsort leading to the notion of QuickXsort. Given some external sorting algorithm X, QuickXsort yields an internal sorting algorithm if X satisfies certain natural conditions. With QuickWeakHeapsort and QuickMergesort we present two examples for the QuickXsort-construction. Both are efficient algorithms that incur approximately n log n - 1.26n +o(n) comparisons on the average. A worst case of n log n + O(n) comparisons can be achieved without significantly affecting the average case. Furthermore, we describe an implementation of MergeInsertion for small n. Taking MergeInsertion as a base case for QuickMergesort, we establish a worst-case efficient sorting algorithm calling for n log n - 1.3999n + o(n) comparisons on average. QuickMergesort with constant size base cases shows the best performance on practical inputs: when sorting integers it is slower by only 15% to STL-Introsort

    QuickXsort: A Fast Sorting Scheme in Theory and Practice

    Get PDF
    QuickXsortis a highly efficient in-place sequential sorting scheme that mixesHoare’sQuicksortalgorithm with X, where X can be chosen from a wider rangeof other known sorting algorithms, likeHeapsort,InsertionsortandMergesort.Its major advantage is thatQuickXsortcan be in-place even if X is not. In thiswork we provide general transfer theorems expressing the number of comparisonsofQuickXsortin terms of the number of comparisons of X. More specifically,if pivots are chosen as medians of (not too fast) growing size samples, the aver-age number of comparisons ofQuickXsortand X differ only byo(n)-terms. Formedian-of-kpivot selection for some constantk, the difference is a linear term whosecoefficient we compute precisely. For instance, median-of-threeQuickMergesortuses at mostnlgn−0.8358n+O(logn)comparisons. Furthermore, we examine thepossibility of sorting base cases with some other algorithm using even less compar-isons. By doing so the average-case number of comparisons can be reduced down tonlgn−1.4112n+o(n)for a remaining gap of only 0.0315ncomparisons to the knownlower bound (while using onlyO(logn)additional space andO(nlogn)time over-all). Implementations of these sorting strategies show that the algorithms challengewell-established library implementations like Musser’sIntrosort

    Weak heaps and friends:recent developments

    Get PDF

    Average Cost of QuickXsort with Pivot Sampling

    Get PDF
    QuickXsort is a strategy to combine Quicksort with another sorting method X, so that the result has essentially the same comparison cost as X in isolation, but sorts in place even when X requires a linear-size buffer. We solve the recurrence for QuickXsort precisely up to the linear term including the optimization to choose pivots from a sample of k elements. This allows to immediately obtain overall average costs using only the average costs of sorting method X (as if run in isolation). We thereby extend and greatly simplify the analysis of QuickHeapsort and QuickMergesort with practically efficient pivot selection, and give the first tight upper bounds including the linear term for such methods

    Multiparty Selection

    Get PDF
    Given a sequence A of n numbers and an integer (target) parameter 1 ? i ? n, the (exact) selection problem is that of finding the i-th smallest element in A. An element is said to be (i,j)-mediocre if it is neither among the top i nor among the bottom j elements of S. The approximate selection problem is that of finding an (i,j)-mediocre element for some given i,j; as such, this variant allows the algorithm to return any element in a prescribed range. In the first part, we revisit the selection problem in the two-party model introduced by Andrew Yao (1979) and then extend our study of exact selection to the multiparty model. In the second part, we deduce some communication complexity benefits that arise in approximate selection. In particular, we present a deterministic protocol for finding an approximate median among k players
    corecore