Skip to main content

An In-Place Priority Queue with O(1) Time for Push and \(\lg n + O(1)\) Comparisons for Pop

  • Conference paper
  • First Online:
Computer Science -- Theory and Applications (CSR 2015)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 9139))

Included in the following conference series:

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. (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. (2)

    To speed up \( push \), we buffer insertions and allow \(O(\lg ^2 n)\) nodes to violate heap order in relation to their parents.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. Brown, M.R.: Implementation and analysis of binomial queue algorithms. SIAM J. Comput. 7(3), 298–319 (1978)

    Article  MATH  MathSciNet  Google Scholar 

  2. Carlsson, S.: A variant of heapsort with almost optimal number of comparisons. Inf. Process. Lett. 24(4), 247–250 (1987)

    Article  MATH  MathSciNet  Google Scholar 

  3. Carlsson, S.: An optimal algorithm for deleting the root of a heap. Inform. Process. Lett. 37(2), 117–120 (1991)

    Article  MATH  MathSciNet  Google Scholar 

  4. Carlsson, S., Chen, J., Mattsson, C.: Heaps with bits. Theor. Comput. Sci. 164(1–2), 1–12 (1996)

    Article  MATH  MathSciNet  Google Scholar 

  5. 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)

    Google Scholar 

  6. 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)

    Chapter  Google Scholar 

  7. Dutton, R.D.: Weak-heap sort. BIT 33(3), 372–381 (1993)

    Article  MathSciNet  Google Scholar 

  8. Edelkamp, S., Elmasry, A., Katajainen, J.: Weak heaps engineered. J. Discrete Algorithms 23, 83–97 (2013). Presented at IWOCA 2012

    Article  MATH  MathSciNet  Google Scholar 

  9. Elmasry, A.: Layered heaps. In: Hagerup, T., Katajainen, J. (eds.) SWAT 2004. LNCS, vol. 3111, pp. 212–222. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  10. Elmasry, A., Jensen, C., Katajainen, J.: Multipartite priority queues. ACM Trans. Algorithms 5(1), 14:1–14:19 (2008). Article no. 14

    Article  MathSciNet  Google Scholar 

  11. Elmasry, A., Katajainen, J.: Towards ultimate binary heaps. CPH STL Report 2013–1, Department of Computer Science, University of Copenhagen (2013)

    Google Scholar 

  12. Floyd, R.W.: Algorithm 245: Treesort 3. Commun. ACM 7(12), 701 (1964)

    Article  Google Scholar 

  13. Gonnet, G.H., Munro, J.I.: Heaps on heaps. SIAM J. Comput 15(4), 964–971 (1986). Presented at ICALP 1982

    Article  MATH  MathSciNet  Google Scholar 

  14. Katajainen, J.: The ultimate heapsort. In: Lin, X. (ed.) CATS 1998. Australian Computer Science Communications, vol. 20, pp. 87–95. Springer, Singapore (1998)

    Google Scholar 

  15. Knuth, D.E.: The Art of Computer Programming: Sorting and Searching, vol. 3, 2nd edn. Addison Wesley Longman, Reading (1998)

    Google Scholar 

  16. McDiarmid, C.J.H., Reed, B.A.: Building heaps fast. J. Algorithms 10(3), 352–365 (1989)

    Article  MATH  MathSciNet  Google Scholar 

  17. Vuillemin, J.: A data structure for manipulating priority queues. Commun. ACM 21(4), 309–315 (1978)

    Article  MATH  MathSciNet  Google Scholar 

  18. 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

    Article  MATH  MathSciNet  Google Scholar 

  19. Williams, J.W.J.: Algorithm 232: Heapsort. Commun. ACM 7(6), 347–348 (1964)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Jyrki Katajainen .

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics