Efficient heaps in purely functional languages

后端 未结 9 1868
被撕碎了的回忆
被撕碎了的回忆 2021-01-30 13:42

As an exercise in Haskell, I\'m trying to implement heapsort. The heap is usually implemented as an array in imperative languages, but this would be hugely inefficient in purely

相关标签:
9条回答
  • 2021-01-30 14:12

    I tried to port standard binary heap into functional settings. There is an article with described idea: A Functional Approach to Standard Binary Heaps. All the source code listings in the article are in Scala. But it might be ported very easy into any other functional language.

    0 讨论(0)
  • 2021-01-30 14:15

    And here is a Fibonacci Heap in Haskell:

    https://github.com/liuxinyu95/AlgoXY/blob/algoxy/datastruct/heap/other-heaps/src/FibonacciHeap.hs

    Here are the pdf file for some other k-ary heaps based on Okasaki's work.

    https://github.com/downloads/liuxinyu95/AlgoXY/kheap-en.pdf

    0 讨论(0)
  • 2021-01-30 14:15

    Here is a page containing an ML version of HeapSort. It's quite detailed and should provide a good starting point.

    http://flint.cs.yale.edu/cs428/coq/doc/Reference-Manual021.html

    0 讨论(0)
提交回复
热议问题