Abstract
An in-place priority queue is a data structure that is stored in an array, uses constant extra space in addition to the array elements, and supports the operations \( top \) (\( find \)-\( min \)), \( push \) (\( insert \)), and \( pop \) (\( delete \)-\( min \)). In this paper we introduce an in-place priority queue, for which \( top \) and \( push \) take O(1) worst-case time, and \( pop \) takes \(O(\lg {} n)\) worst-case time and involves at most \(\lg {} n + O(1)\) element comparisons, where n denotes the number of elements currently in the data structure. The achieved bounds are optimal to within additive constant terms for the number of element comparisons, hereby solving a long-standing open problem. Compared to binary heaps, we surpass the comparison bound for \( pop \) and the time bound for \( push \). Our data structure is similar to a binary heap with two crucial differences:
-
(1)
To improve the comparison bound for \( pop \), we reinforce a stronger heap order at the bottom levels of the heap such that the element at any right child is not smaller than that at its left sibling.
-
(2)
To speed up \( push \), we buffer insertions and allow \(O(\lg ^2 n)\) nodes to violate heap order in relation to their parents.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
References
Brown, M.R.: Implementation and analysis of binomial queue algorithms. SIAM J. Comput. 7(3), 298–319 (1978)
Carlsson, S.: A variant of heapsort with almost optimal number of comparisons. Inf. Process. Lett. 24(4), 247–250 (1987)
Carlsson, S.: An optimal algorithm for deleting the root of a heap. Inform. Process. Lett. 37(2), 117–120 (1991)
Carlsson, S., Chen, J., Mattsson, C.: Heaps with bits. Theor. Comput. Sci. 164(1–2), 1–12 (1996)
Carlsson, S., Munro, J.I., Poblete, P.V.: An implicit binomial queue with constant insertion time. In: Karlsson, R., Lingas, A. (eds.) SWAT 1988. LNCS, vol. 318, pp. 1–13. Springer, Heidelberg (1988)
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)
Dutton, R.D.: Weak-heap sort. BIT 33(3), 372–381 (1993)
Edelkamp, S., Elmasry, A., Katajainen, J.: Weak heaps engineered. J. Discrete Algorithms 23, 83–97 (2013). Presented at IWOCA 2012
Elmasry, A.: Layered heaps. In: Hagerup, T., Katajainen, J. (eds.) SWAT 2004. LNCS, vol. 3111, pp. 212–222. Springer, Heidelberg (2004)
Elmasry, A., Jensen, C., Katajainen, J.: Multipartite priority queues. ACM Trans. Algorithms 5(1), 14:1–14:19 (2008). Article no. 14
Elmasry, A., Katajainen, J.: Towards ultimate binary heaps. CPH STL Report 2013–1, Department of Computer Science, University of Copenhagen (2013)
Floyd, R.W.: Algorithm 245: Treesort 3. Commun. ACM 7(12), 701 (1964)
Gonnet, G.H., Munro, J.I.: Heaps on heaps. SIAM J. Comput 15(4), 964–971 (1986). Presented at ICALP 1982
Katajainen, J.: The ultimate heapsort. In: Lin, X. (ed.) CATS 1998. Australian Computer Science Communications, vol. 20, pp. 87–95. Springer, Singapore (1998)
Knuth, D.E.: The Art of Computer Programming: Sorting and Searching, vol. 3, 2nd edn. Addison Wesley Longman, Reading (1998)
McDiarmid, C.J.H., Reed, B.A.: Building heaps fast. J. Algorithms 10(3), 352–365 (1989)
Vuillemin, J.: A data structure for manipulating priority queues. Commun. ACM 21(4), 309–315 (1978)
Wegener, I.: The worst case complexity of McDiarmid and Reed’s variant of Bottom-up Heapsort is less than \(n\log n + 1.1n\). Inf. Comput. 97(1), 86–96 (1992). Presented at STACS 1991
Williams, J.W.J.: Algorithm 232: Heapsort. Commun. ACM 7(6), 347–348 (1964)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2015 Springer International Publishing Switzerland
About this paper
Cite this paper
Edelkamp, S., Elmasry, A., Katajainen, J. (2015). An In-Place Priority Queue with O(1) Time for Push and \(\lg n + O(1)\) Comparisons for Pop. In: Beklemishev, L., Musatov, D. (eds) Computer Science -- Theory and Applications. CSR 2015. Lecture Notes in Computer Science(), vol 9139. Springer, Cham. https://doi.org/10.1007/978-3-319-20297-6_14
Download citation
DOI: https://doi.org/10.1007/978-3-319-20297-6_14
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-20296-9
Online ISBN: 978-3-319-20297-6
eBook Packages: Computer ScienceComputer Science (R0)