Hostname: page-component-76fb5796d-25wd4 Total loading time: 0 Render date: 2024-04-26T11:40:12.980Z Has data issue: false hasContentIssue false

Optimal purely functional priority queues

Published online by Cambridge University Press:  07 November 2008

Gerth Stølting Brodal*
Affiliation:
BRICS,† Department of Computer Science, University of Aarhus, Ny Munkegade, DK-8000 Århus C, Denmark (e-mail: gerth@daimi.aau.dk)
Chris Okasaki*
Affiliation:
School of Computer Science, Carnegie Mellon University, 5000 Forbes Avenue, Pittsburgh, PA 15213, USA (e-mail: cokasaki@cs.cmu.edu)
*
*Research partially supported by the ESPRIT II Basic Research Actions Program of the EC under contract no. 7141 (project ALCOM II) and by the Danish Natural Science Research Council (Grant No. 9400044).
Research supported by the Advanced Research Projects Agency CSTO under the title “The Fox Project: Advanced Languages for Systems Software”, ARPA Order No. C533, issued by ESC/ENS under Contract No. F19628-95-C-0050.
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

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) worst-case 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.

Type
Articles
Copyright
Copyright © Cambridge University Press 1996

Footnotes

Basic Research in Computer Science, Centre of the Danish National Research Foundation.

References

Brodal, G. S. (1995) Fast meldable priority queues. Workshop on Algorithms and Data Structures: Lecture Notes in Computer Science 955 pp. 282290. Springer-Verlag.CrossRefGoogle Scholar
Brodal, G. S. (1996) Worst-case priority queues. ACM-SIAM Symposium on Discrete Algorithms pp. 5258.Google Scholar
Brown, M. R. (1978) Implementation and analysis of binomial queue algorithms. SIAM J. Computing 7(3):298319.Google Scholar
Buchsbaum, A. L. and Tarjan, R. E. (1995) Confluently persistent deques via data structural bootstrapping. J. Algorithms 18(3):513547.CrossRefGoogle Scholar
Buchsbaum, A. L., Sundar, R. and Tarjan, R. E. (1995) Data-structural bootstrapping, linear path compression, and catenable heap-ordered double-ended queues. SIAM J. Computing 24(6):11901206.CrossRefGoogle Scholar
Crane, C. A. (1972) Linear lists and priority queues as balanced binary trees. PhD thesis, Computer Science Department, Stanford University. (Available as STAN-CS-72-259.)Google Scholar
Driscoll, J. R., Sarnak, N., Sleator, D. D. K. and Tarjan, R. E. (1989) Making data structures persistent. J. Computer and System Sciences 38(1):86124.Google Scholar
Fredman, M. L. and Tarjan, R. E. (1987) Fibonacci heaps and their uses in improved network optimization algorithms. J. ACM 34(3):596615.Google Scholar
Fredman, M. L., Sedgewick, R., Sleator, D. D. K. and Tarjan, R. E. (1986) The pairing heap: A new form of self-adjusting heap. Algorithmica 1(1):111129.Google Scholar
Hood, R. (1982) The Efficient Implementation of Very-High-Level Programming Language Constructs. PhD thesis, Department of Computer Science, Cornell University. (Available as Cornell TR 82-503.)Google Scholar
Hoogerwoord, R. R. (1992) A logarithmic implementation of flexible arrays. Conference on Mathematics of Program Construction: Lecture Notes in Computer Science 669 pp. 191207. Springer-Verlag.Google Scholar
Hudak, P., Peyton Jones, S., Wadler, P., Boutel, B., Fairbairn, J., Fasel, J., Guzḿn, M., Hammond, K., Hughes, J., Johnsson, T., Kieburtz, D., Nikhil, R., Partain, W. and Peterson, J. (1992) Report on the functional programming language Haskell, Version 1.2. SIGPLAN Notices 27(5).CrossRefGoogle Scholar
Jones, D. W. (1986) An empirical comparison of priority-queue and event-set implementations. Comm. ACM 29(4):300311.Google Scholar
Kaldewaij, A. and Schoenmakers, B. (1991) The derivation of a tighter bound for top-down skew heaps. Information Processing Letters 37(5):265271.Google Scholar
Kaplan, H. and Tarjan, R. E. (1995) Persistent lists with catenation via recursive slow-down. ACM Symposium on Theory of Computing pp. 93102.Google Scholar
King, D. J. (1994) Functional binomial queues. Glasgow Workshop on Functional Programming pp. 141150.Google Scholar
MacQueen, D. B. and Tofte, M. (1994) A semantics for higher-order functors. European Symposium on Programming pp. 409423.CrossRefGoogle Scholar
Milner, R., Tofte, M. and Harper, R. (1990) The Definition of Standard ML. The MIT Press.Google Scholar
Myers, E. W. (1983) An applicative random-access stack. Information Processing Letters 17(5):241248.CrossRefGoogle Scholar
Okasaki, C. (1995a) Amortization, lazy evaluation, and persistence: Lists with catenation via lazy linking. IEEE Symposium on Foundations of Computer Science pp. 646654.Google Scholar
Okasaki, C. (1995b) Purely functional random-access lists. Conference on Functional Programming Languages and Computer Architecture pp. 8695.CrossRefGoogle Scholar
Okasaki, C. (1995c) Simple and efficient purely functional queues and deques. J. Functional Programming 5(4):583592.Google Scholar
Okasaki, C. (1996) The role of lazy evaluation in amortized data structures. ACM SIGPLAN International Conference on Functional Programming pp. 6272.Google Scholar
Paulson, L. C. (1991) ML for the Working Programmer. Cambridge University Press.Google Scholar
Schoenmakers, B. (1992) Data Structures and Amortized Complexity in a Functional Setting. PhD thesis, Eindhoven University of Technology.Google Scholar
Sleator, D. D. K. and Tarjan, R. E. (1985) Self-adjusting binary search trees. J. ACM, 32(3):652686.CrossRefGoogle Scholar
Sleator, D. D. K. and Tarjan, R. E. (1986) Self-adjusting heaps. SIAM J. Computing 15(1):5269.CrossRefGoogle Scholar
Tarjan, R. E. (1983) Data Structures and Network Algorithms. CBMS Regional Conference Series in Applied Mathematics, vol. 44. Society for Industrial and Applied Mathematics.Google Scholar
Vuillemin, J. (1978) A data structure for manipulating priority queues. Comm. ACM 21(4):309315.CrossRefGoogle Scholar
Wadler, P. (1990) Linear types can change the world! Proceedings of the IFIP TC 2 Working Conference on Programming Concepts and Methods pp. 561581.Google Scholar
Williams, J. W. J. (1964) Algorithm 232: Heapsort. Comm. ACM 7(6):347348.Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.