Efficient heaps in purely functional languages

There are a number of Haskell heap implementations in an appendix to Okasaki’s Purely Functional Data Structures (pdf). (The source code can be downloaded at the link. The book itself is well worth reading.) None of them are binary heaps, per se, but the “leftist” heap is very similar. It has O(log n) insertion, removal, and merge operations. There are also more complicated data structures like skew heaps, binomial heaps, and splay heaps which have better performance.

Leave a Comment

tech