Acta Informatica

, Volume 22, Issue 2, pp 171–186 | Cite as

An algorithm for merging meaps

  • Jörg -R. Sack
  • Thomas Strothotte


We present an algorithm to merge priority queues organized as heaps. The worst case number of comparisons required to merge two heaps of sizes k and n is O(log(n)*log(k)). The algorithm requires O(k) +log(n)*log (k)) data movements if heaps are implemented using arrays and O(log(n)*log(k)) for a pointer-based implementation. Previous algorithms require either O(n+k) data movements and comparisons, or O(k*log(log(n+k))) comparisons and O(k*log(n+k)) data movements. The algorithm presented in this paper improves on the previous algorithms for the case when k>log(n).


Information System Operating System Data Structure Communication Network Information Theory 
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.
    Aho, A.V., Hopcroft, J.E., Ullman, J.D.: The design and analysis of computer algorithms, p. 99. Reading, MA: Addison-Wesley 1974Google Scholar
  2. 2.
    Aho, A.V., Hopcroft, J.E., Ullman, J.D.: Data structures and algorithms. Reading, MA: Addison-Wesley 1983Google Scholar
  3. 3.
    Brown, M.R.: The analysis of a practical and nearly optimal priority queue. New York: Garland Publishing 1980Google Scholar
  4. 4.
    Floyd, R.W.: Algorithm 245, Treesort 3. CACM 7, 701 (1964)Google Scholar
  5. 5.
    Francon, J., Viennot, G., Vuillemin, J.: Description and analysis of an efficient priority queue representation. Proc. 19th Ann. Symp. Found. Comput Sci. MI: Ann Arbor, pp. 1–7 (1978)Google Scholar
  6. 6.
    Gonnet, G.H.: A handbook of algorithms and data structures. Reading, MA: Addison-Wesley 1984Google Scholar
  7. 7.
    Gonnet, G.H., Munro, I.J.: Heaps on Heaps. Proc. ICALP, Aarhus 9, pp.282–291 (July 1982)Google Scholar
  8. 8.
    Knuth, D.E.: The art of computer programming. Vol. 3: Sorting and searching. Reading, MA: Addison-Wesley 1973Google Scholar
  9. 9.
    Tarjan, R.E.: Data Structures and Network Algorithms. Philadelphia, PA: Soc. Ind. Appl. Math. 1983Google Scholar
  10. 10.
    Vuillemin, J.: A data structure for manipulating priority queues. CACM 21, 309–315 (1978)Google Scholar
  11. 11.
    Williams, J.W.J.: Algorithm 232, heapsort. CACM 7, 347–348 (1964)Google Scholar

Copyright information

© Springer-Verlag 1985

Authors and Affiliations

  • Jörg -R. Sack
    • 1
  • Thomas Strothotte
    • 2
  1. 1.School of Computer ScienceCarleton UniversityOttawaCanada
  2. 2.INRIA RocquencourtLe ChesnayFrance

Personalised recommendations