Abstract
Very recently a new data structure, called a min-max heap, was presented for implementing the double-ended priority queue. A min-max heap onn keys is constructed inO(n) time; the minimum and maximum keys are found in constant time, and the operations of deleting the minimum, deleting the maximum and inserting a new key into the heap are performed inO(logn) time. In addition, the data structure can be stored implicitly, i.e. in an array ofn elements without using any additional pointers.
In this paper, we present lower bound results on the number of comparisons required, in the worst case, for the operations i) to construct a min-max heap on a given set of keys; ii) to convert a min-max heap into a max-min heap; and iii) to merge two min-max heaps into one min-max heap. New upper bounds for the convert and merge operations are also derived. It is found that the main difference between traditional heaps and min-max heaps lies in the time needed to perform the merge operation. While traditional heaps can be merged efficiently, it is shown that min-max heaps are not sublinearly mergeable. Even the seemingly simple task of converting a min-max heap into a max-min heap cannot be performed in less than linear time.
Similar content being viewed by others
References
A. V. Aho, J. E. Hopcroft and J. D. Ullman,The Design and Analysis of Computer Algorithms, Addison-Wesley, Reading, Mass. (1974).
M. D. Atkinson,Mathematics in the service of computer programming, Mathematical Spectrum 10: 1, 6–11 (1977/78).
M. D. Atkinson, J.-R. Sack, N. Santoro ad Th. Strothotte,Min-max heaps and generalized priority queues, Comm. ACM 29: 10, 996–1000 (October 1986).
S. Carlsson,Heaps, Ph.D. Dissertation, Lund University, Lund, Sweden (November 1986).
F. Fussenegger and H. Gabow,A counting approach to lower bounds for selection problems, Comm. ACM 7: 6, 347–348 (June 1964).
G. H. Gonnett and J. I. Munro,Heaps on heaps, Proc. ICALP 9, Aarhus, 282–291 (July 1982).
A. Hasham,A new class of priority queue organizations, M.C.S. Thesis, School of Computer Science, Carleton University (1986).
D. E. Knuth,The Art of Computer Programming, Vol. 3: Sorting and Searching, Addison-Wesley, Reading, Mass (1973).
J.-R. Sack and Th. Strothotte,An algorithm for merging heaps, Acta Informatica 22, 171–186 (1985)
Th. Strothotte and J.-R. Sack,Heaps in heaps, Congressus Numerantium 49, 223–235 (December 1985).
J. W. J. Williams,Algorithm 232: Heapsort, Comm. ACM 7: 6, 347–348 (June 1964).
Author information
Authors and Affiliations
Additional information
This research was supported by the Natural Science and Engineering Council of Canada under Grant No. A0392. (A preliminary version of this paper was presented at the 24th Annual Allerton Conference on Communication, Control and Computing.)