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

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.

[1]  Donald E. Knuth,et al.  The art of computer programming: sorting and searching (volume 3) , 1973 .

[2]  Gaston H. Gonnet,et al.  Heaps on Heaps , 1982, ICALP.

[3]  J. Ian Munro,et al.  An Implicit Binomial Queue with Constant Insertion Time , 1988, SWAT.

[4]  Mark R. Brown,et al.  Implementation and Analysis of Binomial Queue Algorithms , 1978, SIAM J. Comput..

[5]  Jyrki Katajainen The Ultimate Heapsort , 1998, CATS.

[6]  Amr Elmasry,et al.  Multipartite priority queues , 2008, TALG.

[7]  Jean Vuillemin,et al.  A data structure for manipulating priority queues , 1978, CACM.

[8]  Svante Carlsson,et al.  An Optimal Algorithm for Deleting the Root of a Heap , 1991, Inf. Process. Lett..

[9]  Ingo Wegener The Worst Case Complexity of McDiarmid and Reed's Variant of BOTTOM-UP HEAPSORT is less than nlog n + 1.1n , 1992, Inf. Comput..

[10]  Amr Elmasry,et al.  Layered Heaps , 2004, SWAT.

[11]  Amr Elmasry,et al.  In-place Heap Construction with Optimized Comparisons, Moves, and Cache Misses , 2012, MFCS.

[12]  Donald E. Knuth,et al.  The Art of Computer Programming: Volume 3: Sorting and Searching , 1998 .

[13]  Amr Elmasry,et al.  Weak heaps engineered , 2013, J. Discrete Algorithms.

[14]  Bruce A. Reed,et al.  Building Heaps Fast , 1989, J. Algorithms.

[15]  Svante Carlsson A Variant of Heapsort with Almost Optimal Number of Comparisons , 1987, Inf. Process. Lett..

[16]  Ronald D. Dutton,et al.  Weak-heap sort , 1993, BIT.

[17]  Donald E. Knuth,et al.  The art of computer programming, volume 3: (2nd ed.) sorting and searching , 1998 .

[18]  Svante Carlsson,et al.  Heaps with Bits , 1996, Theor. Comput. Sci..