Weak Heaps and Friends: Recent Developments

  • Stefan Edelkamp
  • Amr Elmasry
  • Jyrki Katajainen
  • Armin Weiß
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8288)


A weak heap is a variant of a binary heap where, for each node, the heap ordering is enforced only for one of its two children. In 1993, Dutton showed that this data structure yields a simple worst-case-efficient sorting algorithm. In this paper we review the refinements proposed to the basic data structure that improve the efficiency even further. Ultimately, minimum and insert operations are supported in O(1) worst-case time and extract-min operation in \(O(\lg n)\) worst-case time involving at most \(\lg n + O(1)\) element comparisons. In addition, we look at several applications of weak heaps. This encompasses the creation of a sorting index and the use of a weak heap as a tournament tree leading to a sorting algorithm that is close to optimal in terms of the number of element comparisons performed. By supporting insert operation in O(1) amortized time, the weak-heap data structure becomes a valuable tool in adaptive sorting leading to an algorithm that is constant-factor optimal with respect to several measures of disorder. Also, a weak heap can be used as an intermediate step in an efficient construction of binary heaps. For graph search and network optimization, a weak-heap variant, which allows some of the nodes to violate the weak-heap ordering, is known to be provably better than a Fibonacci heap.


Priority Queue Sorting Algorithm Element Move Left Child Element Comparison 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Bruun, A., Edelkamp, S., Katajainen, J., Rasmussen, J.: Policy-based benchmarking of weak heaps and their relatives. In: Festa, P. (ed.) SEA 2010. LNCS, vol. 6049, pp. 424–435. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  2. 2.
    Cantone, D., Cinotti, G.: QuickHeapsort, an efficient mix of classical sorting algorithms. Theoret. Comput. Sci. 285(1), 25–42 (2002)MathSciNetCrossRefzbMATHGoogle Scholar
  3. 3.
    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
  4. 4.
    Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 3rd edn. The MIT Press (2009)Google Scholar
  5. 5.
    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
  6. 6.
    Driscoll, J.R., Gabow, H.N., Shrairman, R., Tarjan, R.E.: Relaxed heaps: An alternative to Fibonacci heaps with applications to parallel computation. Commun. ACM 31(11), 1343–1354 (1988)MathSciNetCrossRefGoogle Scholar
  7. 7.
    Dutton, R.D.: Weak-heap sort. BIT 33(3), 372–381 (1993)MathSciNetCrossRefGoogle Scholar
  8. 8.
    Edelkamp, S., Elmasry, A., Katajainen, J.: Two constant-factor-optimal realizations of adaptive heapsort. In: Iliopoulos, C.S., Smyth, W.F. (eds.) IWOCA 2011. LNCS, vol. 7056, pp. 195–208. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  9. 9.
    Edelkamp, S., Elmasry, A., Katajainen, J.: The weak-heap family of priority queues in theory and praxis. In: Mestre, J. (ed.) CATS 2012, Conferences in Research and Practice in Information Technology, vol. 128, pp. 103–112. Australian Computer Society, Inc., Adelaide (2012)Google Scholar
  10. 10.
    Edelkamp, S., Elmasry, A., Katajainen, J.: The weak-heap data structure: Variants and applications. J. Discrete Algorithms 16, 187–205 (2012)MathSciNetCrossRefzbMATHGoogle Scholar
  11. 11.
    Edelkamp, S., Elmasry, A., Katajainen, J.: A catalogue of algorithms for building weak heaps. In: Smyth, B. (ed.) IWOCA 2012. LNCS, vol. 7643, pp. 249–262. Springer, Heidelberg (2012)Google Scholar
  12. 12.
    Edelkamp, S., Elmasry, A., Katajainen, J.: Weak heaps engineered. J. Discrete Algorithms (to appear)Google Scholar
  13. 13.
    Edelkamp, S., Elmasry, A., Katajainen, J.: Optimal in-place heaps (submitted)Google Scholar
  14. 14.
    Edelkamp, S., Stiegeler, P.: Implementing Heapsort with n logn − 0.9 n and Quicksort with n logn + 0.2 n comparisons. ACM J. Exp. Algorithmics 7, Article 5 (2002)Google Scholar
  15. 15.
    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
  16. 16.
    Edelkamp, S., Weiss, A.: QuickXsort: Efficient sorting with n log n − 1.399n+o(n) comparisons on average. E-print arXiv:1307.3033,, Ithaca (2013)Google Scholar
  17. 17.
    Elmasry, A., Fredman, M.L.: Adaptive sorting: An information theoretic perspective. Acta Inform. 45(1), 33–42 (2008)MathSciNetCrossRefzbMATHGoogle Scholar
  18. 18.
    Elmasry, A., Hammad, A.: Inversion-sensitive sorting algorithms in practice. ACM J. Exp. Algorithmics 13, Article 1.11 (2009)Google Scholar
  19. 19.
    Elmasry, A., Jensen, C., Katajainen, J.: Multipartite priority queues. ACM Trans. Algorithms 5(1), Article 14 (2008)Google Scholar
  20. 20.
    Elmasry, A., Katajainen, J.: Towards ultimate binary heaps. CPH STL Report 2013-3, Department of Computer Science, University of Copenhagen, Copenhagen (2013)Google Scholar
  21. 21.
    Gonnet, G.H., Munro, J.I.: Heaps on heaps. SIAM J. Comput. 15(4), 964–971 (1986)MathSciNetCrossRefzbMATHGoogle Scholar
  22. 22.
    Katajainen, J.: The ultimate heapsort. In: Lin, X. (ed.) CATS 2012, Australian Computer Science Communications, vol. 20, pp. 87–96. Springer-Verlag Singapore Pte. Ltd., Singapore (1998)Google Scholar
  23. 23.
    Katajainen, J., Vitale, F.: Navigation piles with applications to sorting, priority queues, and priority deques. Nordic J. Comput. 10(3), 238–262 (2003)MathSciNetzbMATHGoogle Scholar
  24. 24.
    Knuth, D.E.: Sorting and Searching, The Art of Computer Programming, 2nd edn., vol. 3. Addison Wesley Longman, Reading (1998)Google Scholar
  25. 25.
    Levcopoulos, C., Petersson, O.: Adaptive heapsort. J. Algorithms 14(3), 395–413 (1993)MathSciNetCrossRefzbMATHGoogle Scholar
  26. 26.
    McDiarmid, C.J.H., Reed, B.A.: Building heaps fast. J. Algorithms 10(3), 352–365 (1989)MathSciNetCrossRefzbMATHGoogle Scholar
  27. 27.
    Musser, D.R.: Introspective sorting and selection algorithms. Software Pract. Exper. 27(8), 983–993 (1997)CrossRefGoogle Scholar
  28. 28.
    Vuillemin, J.: A data structure for manipulating priority queues. Commun. ACM 21(4), 309–315 (1978)MathSciNetCrossRefzbMATHGoogle Scholar
  29. 29.
    Wegener, I.: Bottom-up-Heapsort, a new variant of Heapsort beating, on an average, Quicksort (if n is not very small). Theoret. Comput. Sci. 118(1), 81–98 (1993)MathSciNetCrossRefzbMATHGoogle Scholar
  30. 30.
    Williams, J.W.J.: Algorithm 232: Heapsort. Commun. ACM 7(6), 347–348 (1964)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  • Stefan Edelkamp
    • 1
  • Amr Elmasry
    • 2
  • Jyrki Katajainen
    • 3
  • Armin Weiß
    • 4
  1. 1.Faculty 3—Mathematics and Computer ScienceUniversity of BremenBremenGermany
  2. 2.Department of Computer Engineering and SystemsAlexandria UniversityAlexandriaEgypt
  3. 3.Department of Computer ScienceUniversity of CopenhagenCopenhagen EastDenmark
  4. 4.Institute for Formal Methods in Computer ScienceUniversity of StuttgartStuttgartGermany

Personalised recommendations