The weak-heap data structure: Variants and applications

The weak heap is a priority queue that was introduced as a competitive structure for sorting. Its array-based form supports the operations find-min in O(1) worst-case time, and insert and delete-min in O(lgn) worst-case time using at most @[email protected]? element comparisons. Additionally, its pointer-based form supports delete and decrease in O(lgn) worst-case time using at most @[email protected]? element comparisons. In this paper we enhance this data structure as follows:1.We improve the array-based form to support insert in O(1) amortized time. The main idea is to temporarily store the inserted elements in a buffer, and, once the buffer is full, to move its elements to the heap using an efficient bulk-insertion procedure. As an application, we use this variant in the implementation of adaptive heapsort. Accordingly, we guarantee, for several measures of disorder, that the formula expressing the number of element comparisons performed by the algorithm is optimal up to the constant factor of the high-order term. Unlike other previous constant-factor-optimal adaptive sorting algorithms, adaptive heapsort relying on the developed priority queue is practically workable. 2.We improve the pointer-based form to support insert and decrease in O(1) worst-case time per operation. The expense is that delete then requires at most [email protected][email protected]? element comparisons, but this is still better than the [email protected][email protected]? bound known for run-relaxed heaps. The main idea is to allow some nodes to violate the weak-heap ordering; we call the resulting priority queue a relaxed weak heap. We also develop a more efficient amortized variant that provides delete guaranteeing an amortized bound of [email protected][email protected]? element comparisons, which is better than the [email protected]?log"@[email protected]? bound known for Fibonacci heaps, where @f is the golden ratio. As an application, we use this variant in the implementation of [email protected]?s shortest-paths algorithm. Experimental results indicate that weak heaps are practically efficient; they are competitive with other priority-queue structures when considering the number of element comparisons performed, and lose by a small margin when considering the actual running time.

[1]  C. Q. Lee,et al.  The Computer Journal , 1958, Nature.

[2]  Edsger W. Dijkstra,et al.  A note on two problems in connexion with graphs , 1959, Numerische Mathematik.

[3]  Kurt Mehlhorn,et al.  The LEDA Platform of Combinatorial and Geometric Computing , 1997, ICALP.

[4]  Alistair Moffat,et al.  Splaysort: fast, versatile, practical , 1996 .

[5]  Robert E. Tarjan,et al.  Rank-Pairing Heaps , 2009, ESA.

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

[7]  Andrew V. Goldberg,et al.  Shortest paths algorithms: Theory and experimental evaluation , 1994, SODA '94.

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

[9]  Donald E. Knuth,et al.  Sorting and Searching , 1973 .

[10]  Amr Elmasry,et al.  Adaptive Sorting with AVL Trees , 2004, IFIP TCS.

[11]  R. K. Shyamasundar,et al.  Introduction to algorithms , 1996 .

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

[13]  Stefan Edelkamp,et al.  Policy-Based Benchmarking of Weak Heaps and Their Relatives, , 2010, SEA.

[14]  Ronald L. Rivest,et al.  Introduction to Algorithms, third edition , 2009 .

[15]  Robert E. Tarjan,et al.  Relaxed heaps: an alternative to Fibonacci heaps with applications to parallel computation , 1988, CACM.

[16]  Ingo Wegener,et al.  On the Performance of WEAK-HEAPSORT , 2000, STACS.

[17]  Gerth Stølting Brodal,et al.  Cache-Aware and Cache-Oblivious Adaptive Sorting , 2005, ICALP.

[18]  Stefan Edelkamp,et al.  Implementing HEAPSORT with (n logn - 0.9n) and QUICKSORT with (n logn + 0.2n) comparisons , 2002, JEAL.

[19]  Gerth Stølting Brodal,et al.  On the Adaptiveness of Quicksort , 2004 .

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

[21]  John T. Stasko,et al.  Pairing heaps: experiments and analysis , 1987, CACM.

[22]  Robert E. Tarjan,et al.  Data structures and network algorithms , 1983, CBMS-NSF regional conference series in applied mathematics.

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

[24]  Jean Vuillemin,et al.  A unifying look at data structures , 1980, CACM.

[25]  David R. Musser,et al.  Introspective Sorting and Selection Algorithms , 1997, Softw. Pract. Exp..

[26]  P ? ? ? ? ? ? ? % ? ? ? ? , 1991 .

[27]  Amr Elmasry,et al.  Two-tier relaxed heaps , 2006, Acta Informatica.

[28]  Amr Elmasry,et al.  Inversion-sensitive sorting algorithms in practice , 2009, JEAL.

[29]  Robert E. Tarjan,et al.  Scaling and related techniques for geometry problems , 1984, STOC '84.

[30]  Christos Levcopoulos,et al.  Adaptive Heapsort , 1993, J. Algorithms.

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

[32]  Christos Levcopoulos,et al.  Splitsort - An Adaptive Sorting Algorithm , 1990, Inf. Process. Lett..

[33]  Robert E. Tarjan,et al.  Fibonacci heaps and their uses in improved network optimization algorithms , 1984, JACM.

[34]  Robert E. Tarjan,et al.  The pairing heap: A new form of self-adjusting heap , 2005, Algorithmica.

[35]  Riku Saikkonen,et al.  Bulk-Insertion Sort: Towards Composite Measures of Presortedness , 2009, SEA.

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

[37]  R. Prim Shortest connection networks and some generalizations , 1957 .

[38]  Kohei Noshita,et al.  A Theorem on the Expected Complexity of Dijkstra's Shortest Path Algorithm , 1985, J. Algorithms.