Optimal Purely Functional Priority Queues

Gerth Stølting Brodal and Chris Okasaki

Technical Report, BRICS-RS-96-37, BRICS, Department of Computer Science, Aarhus University, 27 pages, October 1996.

Abstract

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.

Copyright notice

Copyright © 1996, BRICS, Department of Computer Science, Aarhus University. All rights reserved.

Online version

brics-rs-96-37.pdf (274 Kb)

BIBTEX entry

@techreport{brics-rs-96-37,
  author = "Gerth St{\o}lting Brodal and Chris Okasaki",
  institution = "BRICS, Department of Computer Science, Aarhus University",
  issn = "0909-0878",
  month = "October",
  number = "BRICS-RS-96-37",
  pages = "27",
  title = "Optimal Purely Functional Priority Queues",
  year = "1996"
}