Optimal purely functional priority queues

Brodal recently introduced the first implementation of imperative priority queues to support findMin, insert, and meld in O(1) worst-case time, and deleteMin in O(log n) worstcase time. These bounds are asymptotically optimal among all comparison-based priority queues. In this paper, we adapt Brodal’s data structure to a purely functional setting. In doing so, we both simplify the data structure and clarify its relationship to the binomial queues of Vuillemin, which support all four operations in O(log n) time. Specifically, we derive our implementation from binomial queues in three steps: first, we reduce the running time of insert to O(1) by eliminating the possibility of cascading links; second, we reduce the running time of findMin to O(1) by adding a global root to hold the minimum element; and finally, we reduce the running time of meld to O(1) by allowing priority queues to contain other priority queues. Each of these steps is expressed using ML-style functors. The last transformation, known as data-structural bootstrapping, is an interesting application of higher-order functors and recursive structures.

[1]  Luca Aceto,et al.  On a Question of A. Salomaa: The Equational Theory of Regular Expressions Over a Singleton Alphabet is not Finitely Based , 1998, Theor. Comput. Sci..

[2]  Chris Okasaki,et al.  Amortization, lazy evaluation, and persistence: lists with catenation via lazy linking , 1995, Proceedings of IEEE 36th Annual Foundations of Computer Science.

[3]  Glynn Winskel,et al.  Presheaf Models for Concurrency , 1996, CSL.

[4]  Robert E. Tarjan,et al.  Making data structures persistent , 1986, STOC '86.

[5]  Berry Schoenmakers,et al.  The Derivation of a Tighter Bound for Top-Down Skew Heaps , 1991, Inf. Process. Lett..

[6]  Lam Berry Schoenmakers,et al.  Data structures and amortized complexity in a functional setting , 1992 .

[7]  Chris Okasaki,et al.  Simple and efficient purely functional queues and deques , 1995, Journal of Functional Programming.

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

[9]  Rob R. Hoogerwoord,et al.  A Logarithmic Implementation of Flexible Arrays , 1992, MPC.

[10]  David J. King Functional Binomial Queues , 1994, Functional Programming.

[11]  P. S. Thiagarajan,et al.  Regular Trace Event Structures , 1996 .

[12]  Douglas W. Jones,et al.  An empirical comparison of priority-queue and event-set implementations , 1986, CACM.

[13]  Simon L. Peyton Jones,et al.  Report on the programming language Haskell: a non-strict, purely functional language version 1.2 , 1992, SIGP.

[14]  Robin Milner,et al.  Definition of standard ML , 1990 .

[15]  Chris Okasaki,et al.  The role of lazy evaluation in amortized data structures , 1996, ICFP '96.

[16]  Robert Todd Hood,et al.  The Efficient Implementation of Very-high-level Programming Language Constructs , 1982 .

[17]  Robert E. Tarjan,et al.  Self-Adjusting Heaps , 1986, SIAM J. Comput..

[18]  Philip Wadler,et al.  Linear Types can Change the World! , 1990, Programming Concepts and Methods.

[19]  Chris Okasaki,et al.  Purely functional random-access lists , 1995, FPCA '95.

[20]  Eugene W. Myers,et al.  An Applicative Random-Access Stack , 1983, Inf. Process. Lett..

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

[22]  R. Tarjan,et al.  Con uently Persistent Deques via Data-Structural Bootstrapping 1 , 1993 .

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

[24]  Joyce L. Vedral,et al.  Functional Programming Languages and Computer Architecture , 1989, Lecture Notes in Computer Science.

[25]  Robert E. Tarjan,et al.  Confluently persistent deques via data structuaral bootstrapping , 1993, SODA '93.

[26]  Ian Stark,et al.  Names, Equations, Relations: Practical Ways to Reason About New , 1996, Fundam. Informaticae.

[27]  Lars Arge,et al.  The I/O - Complexity of Ordered Binary - Decision Diagram Manipulation , 1995, ISAAC.

[28]  Robert E. Tarjan,et al.  Self-adjusting binary search trees , 1985, JACM.

[29]  G. Brodal,et al.  Optimal Purely Functional Priority Queues , 1996 .

[30]  Robert E. Tarjan,et al.  Data-Structural Bootstrapping, Linear Path Compression, and Catenable Heap-Ordered Double-Ended Queues , 1995, SIAM J. Comput..

[31]  Haim Kaplan,et al.  Persistent lists with catenation via recursive slow-down , 1995, STOC '95.

[32]  Gerth Stølting Brodal,et al.  Fast Meldable Priority Queues , 1995, WADS.

[33]  Clark A. Crane,et al.  Linear Lists and Prorty Queues as Balanced Binary Trees , 1972, Outstanding Dissertations in the Computer Sciences.

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

[35]  Olivier Danvy,et al.  A Computational Formalization for Partial Evaluation (Extended Version) , 1996 .

[36]  Mads Tofte,et al.  A Semantics for Higher-Order Functors , 1994, ESOP.