A Characterization of Heaps and Its Applications

Abstract In this paper we present a new view of a classical data structure, the heap. We view a heap on n elements as an ordered collection of ⌜log2(n + 1)⌝ substructures of sizes 2i with i in {0, …, ⌈log2(n)⌉}. We use the new view in the design of an algorithm for splitting a heap on n elements into two heaps on k and n − k elements, respectively. The algorithm requires O(log2(n)) comparisons, improving the previous bound of O(k) comparisons for all but small values of k, i.e., for k log2(n). We also present a new and conceptually simple algorithm for merging heaps of sizes n and k into one heap of size n + k in O( log (n) ∗ log (k)) comparisons.

[1]  Alfred V. Aho,et al.  The Design and Analysis of Computer Algorithms , 1974 .

[2]  Donald Ervin Knuth,et al.  The Art of Computer Programming , 1968 .

[3]  Mark R. Brown The Analysis of a Practical and Nearly Optimal Priorty Queue , 1977, Outstanding Dissertations in the Computer Sciences.

[4]  J. Ian Munro,et al.  Implicit Data Structures for Fast Search and Update , 1980, J. Comput. Syst. Sci..

[5]  Thomas Strothotte,et al.  An Algorithm for Merging Heaps , 1985, Acta Informatica.

[6]  Gaston H. Gonnet,et al.  Heaps on Heaps , 1982, SIAM J. Comput..

[7]  Gaston H. Gonnet,et al.  Handbook Of Algorithms And Data Structures , 1984 .