QuickXsort: Efficient Sorting with n logn − 1.399n + o(n) Comparisons on Average

  • Stefan Edelkamp
  • Armin Weiß
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8476)


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. We show that up to o(n) terms the average number of comparisons incurred by QuickXsort is equal to the average number of comparisons of X.

We also describe a new variant of WeakHeapsort. With QuickWeakHeapsort and QuickMergesort we present two examples for the QuickXsort construction. Both are efficient algorithms that perform approximately n logn − 1.26n + o(n) comparisons on average. Moreover, we show that this bound also holds for a slight modification which guarantees an \(n \log n + \mathcal{O}(n)\) bound for the worst case number of comparisons.

Finally, we describe an implementation of MergeInsertion and analyze its average case behavior. Taking MergeInsertion as a base case for QuickMergesort, we establish an efficient internal sorting algorithm calling for at most n logn − 1.3999n + o(n) comparisons on average. QuickMergesort with constant size base cases shows the best performance on practical inputs and is competitive to STL-Introsort.


in-place sorting quicksort mergesort analysis of algorithms 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Blum, M., Floyd, R.W., Pratt, V., Rivest, R.L., Tarjan, R.E.: Time bounds for selection. J. Comput. Syst. Sci. 7(4), 448–461 (1973)CrossRefzbMATHMathSciNetGoogle Scholar
  2. 2.
    Cantone, D., Cinotti, G.: QuickHeapsort, an efficient mix of classical sorting algorithms. Theoretical Computer Science 285(1), 25–42 (2002)CrossRefzbMATHMathSciNetGoogle Scholar
  3. 3.
    Diekert, V., Weiß, A.: Quickheapsort: Modifications and improved analysis. In: Bulatov, A.A., Shur, A.M. (eds.) CSR 2013. LNCS, vol. 7913, pp. 24–35. Springer, Heidelberg (2013)CrossRefGoogle Scholar
  4. 4.
    Dutton, R.D.: Weak-heap sort. BIT 33(3), 372–381 (1993)CrossRefMathSciNetGoogle Scholar
  5. 5.
    Edelkamp, S., Stiegeler, P.: Implementing HEAPSORT with n logn − 0.9n and QUICKSORT with n logn + 0.2 n comparisons. ACM Journal of Experimental Algorithmics 10(5) (2002)Google Scholar
  6. 6.
    Edelkamp, S., Wegener, I.: On the performance of WEAK − HEAPSORT. In: Reichel, H., Tison, S. (eds.) STACS 2000. LNCS, vol. 1770, pp. 254–266. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  7. 7.
    Edelkamp, S., Weiß, A.: QuickXsort: Efficient Sorting with n logn − 1.399n + o(n) Comparisons on Average. ArXiv e-prints, abs/1307.3033 (2013)Google Scholar
  8. 8.
    Elmasry, A., Katajainen, J., Stenmark, M.: Branch mispredictions don’t affect mergesort. In: Klasing, R. (ed.) SEA 2012. LNCS, vol. 7276, pp. 160–171. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  9. 9.
    Ford, J., Lester, R., Johnson, S.M.: A tournament problem. The American Mathematical Monthly 66(5), 387–389 (1959)CrossRefzbMATHMathSciNetGoogle Scholar
  10. 10.
    Katajainen, J.: The Ultimate Heapsort. In: CATS, pp. 87–96 (1998)Google Scholar
  11. 11.
    Katajainen, J., Pasanen, T., Teuhola, J.: Practical in-place mergesort. Nord. J. Comput. 3(1), 27–40 (1996)MathSciNetGoogle Scholar
  12. 12.
    Knuth, D.E.: Sorting and Searching, 2nd edn. The Art of Computer Programming, vol. 3. Addison Wesley Longman (1998)Google Scholar
  13. 13.
    Martínez, C., Roura, S.: Optimal Sampling Strategies in Quicksort and Quickselect. SIAM J. Comput. 31(3), 683–705 (2001)CrossRefzbMATHMathSciNetGoogle Scholar
  14. 14.
    Musser, D.R.: Introspective sorting and selection algorithms. Software—Practice and Experience 27(8), 983–993 (1997)CrossRefGoogle Scholar
  15. 15.
    Reinhardt, K.: Sorting in-place with a worst case complexity of n logn − 1.3 n + o(logn) comparisons and εn logn + o(1) transports. In: Ibaraki, T., Iwama, K., Yamashita, M., Inagaki, Y., Nishizeki, T. (eds.) ISAAC 1992. LNCS, vol. 650, pp. 489–498. Springer, Heidelberg (1992)CrossRefGoogle Scholar
  16. 16.
    Wegener, I.: Bottom-up-Heapsort, a new variant of Heapsort beating, on an average, Quicksort (if n is not very small). Theoretical Computer Science 118(1), 81–98 (1993)CrossRefzbMATHMathSciNetGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2014

Authors and Affiliations

  • Stefan Edelkamp
    • 1
  • Armin Weiß
    • 2
  1. 1.TZIUniversität BremenBremenGermany
  2. 2.FMIUniversität StuttgartStuttgartGermany

Personalised recommendations