QuickHeapsort: Modifications and Improved Analysis

  • Volker Diekert
  • Armin Weiß
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7913)


We present a new analysis for QuickHeapsort. This enables us to consider samples of non-constant size for the pivot selection and leads to better theoretical bounds for the algorithm. Furthermore, we introduce some modifications of QuickHeapsort, both in-place and using n extra bits. We show that on every input the expected number of comparisons is \(n\lg n - 0.03n + o(n)\) (in-place) respectively \( n\lg n -0.997 n+ o (n)\) (always \(\lg n= \log_2 n\)). Both estimates improve the previously known best results. (It is conjectured [17] that the in-place algorithm Bottom-Up-Heapsort uses at most \(n\lg n + 0.4 n\) on average and for Weak-Heapsort which uses n extra bits the average number of comparisons is at most \(n\lg n -0.42n\) [8].) Moreover, our non-in-place variant can even compete with index based Heapsort variants (e.g. Rank-Heapsort [15]) and Relaxed-Weak-Heapsort (\( n\lg n -0.9 n+ o (n)\) comparisons in the worst case) for which no \(\mathcal{O}(n)\)-bound on the number of extra bits is known.


in-place sorting heapsort quicksort 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)MathSciNetMATHCrossRefGoogle Scholar
  2. 2.
    Cantone, D., Cincotti, G.: Quickheapsort, an efficient mix of classical sorting algorithms. Theor. Comput. Sci. 285(1), 25–42 (2002)MathSciNetMATHCrossRefGoogle Scholar
  3. 3.
    Carlsson, S., Chen, J., Mattsson, C.: Heaps with Bits. In: Du, D.-Z., Zhang, X.-S. (eds.) ISAAC 1994. LNCS, vol. 834, pp. 288–296. Springer, Heidelberg (1994)CrossRefGoogle Scholar
  4. 4.
    Chen, J.: A Framework for Constructing Heap-like structures in-place. In: Ng, K.W., Balasubramanian, N.V., Raghavan, P., Chin, F.Y.L. (eds.) ISAAC 1993. LNCS, vol. 762, pp. 118–127. Springer, Heidelberg (1993)CrossRefGoogle Scholar
  5. 5.
    Chen, J., Edelkamp, S., Elmasry, A., Katajainen, J.: In-place Heap Construction with Optimized Comparisons, Moves, and Cache Misses. In: Rovan, B., Sassone, V., Widmayer, P. (eds.) MFCS 2012. LNCS, vol. 7464, pp. 259–270. Springer, Heidelberg (2012)CrossRefGoogle Scholar
  6. 6.
    Diekert, V., Weiss, A.: Quickheapsort: Modifications and improved analysis. ArXiv e-prints, abs/1209.4214 (2012)Google Scholar
  7. 7.
    Dutton, R.D.: Weak-heap sort. BIT 33(3), 372–381 (1993)MathSciNetCrossRefGoogle Scholar
  8. 8.
    Edelkamp, S., Stiegeler, P.: Implementing HEAPSORT with n logn − 0.9n and QUICKSORT with n logn + 0.2n comparisons. ACM Journal of Experimental Algorithmics 7, 5 (2002)MathSciNetCrossRefGoogle Scholar
  9. 9.
    Floyd, R.W.: Algorithm 245: Treesort. Commun. ACM 7(12), 701 (1964)CrossRefGoogle Scholar
  10. 10.
    Gonnet, G.H., Munro, J.I.: Heaps on Heaps. SIAM J. Comput. 15(4), 964–971 (1986)MathSciNetMATHCrossRefGoogle Scholar
  11. 11.
    Katajainen, J.: The Ultimate Heapsort. In: Lin, X. (ed.) CATS. Australian Computer Science Communications, vol. 20, pp. 87–96. Springer-Verlag Singapore Pte. Ltd. (1998)Google Scholar
  12. 12.
    Martínez, C., Roura, S.: Optimal Sampling Strategies in Quicksort and Quickselect. SIAM J. Comput. 31(3), 683–705 (2001)MathSciNetMATHCrossRefGoogle Scholar
  13. 13.
    McDiarmid, C., Reed, B.A.: Building Heaps Fast. J. Algorithms 10(3), 352–365 (1989)MathSciNetMATHCrossRefGoogle Scholar
  14. 14.
    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., Inagaki, Y., Iwama, K., Nishizeki, T., Yamashita, M. (eds.) ISAAC 1992. LNCS, vol. 650, pp. 489–498. Springer, Heidelberg (1992)CrossRefGoogle Scholar
  15. 15.
    Wang, X.-D., Wu, Y.-J.: An Improved HEAPSORT Algorithm with nlogn − 0.788928n Comparisons in the Worst Case. Journal of Computer Science and Technology 22, 898–903 (2007), doi:10.1007/s11390-007-9106-7MathSciNetCrossRefGoogle Scholar
  16. 16.
    Wegener, I.: The Worst Case Complexity of McDiarmid and Reed’s Variant of Bottom-Up-Heap Sort is Less Than n logn + 1.1n. In: Jantzen, M., Choffrut, C. (eds.) STACS 1991. LNCS, vol. 480, pp. 137–147. Springer, Heidelberg (1991)CrossRefGoogle Scholar
  17. 17.
    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)MathSciNetMATHCrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  • Volker Diekert
    • 1
  • Armin Weiß
    • 1
  1. 1.FMIUniversität StuttgartStuttgartGermany

Personalised recommendations