Efficient heaps in purely functional languages
Posted
by Kim
on Stack Overflow
See other posts from Stack Overflow
or by Kim
Published on 2009-05-31T19:52:23Z
Indexed on
2010/05/24
1:00 UTC
Read the original article
Hit count: 348
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 functional languages. So I've looked at binary heaps, but everything I found so far describes them from an imperative viewpoint and the algorithms presented are hard to translate to a functional setting. How to efficiently implement a heap in a purely functional language such as Haskell?
Edit: By efficient I mean it should still be in O(n*log n), but it doesn't have to beat a C program. Also, I'd like to use purely functional programming. What else would be the point of doing it in Haskell?
© Stack Overflow or respective owner