4 ms·
I might be missing something obvious so excuse me, but why not use a heap as a priority queue? It has O(1) find-minimum and O(log n) insert, which is better tha
by thegeomaster 11y ago
I might be missing something obvious so excuse me, but why not use a heap as a priority queue? It has O(1) find-minimum and O(log n) insert, which is better than a set which is probably some kind of self-balancing BST (I don't speak Haskell).
- coolsunglasses 11y agoYou can use mutable data structures in Haskell but we strive to avoid it except where strictly necessary. To find the "Haskell" version it suffices to add either "Haskell" or "persistent" to the search query for a data structure. Here's a priority queue library for Haskell, if you'd like an example: https://hackage.haskell.org/package/pqueue https://hackage.haskell.org/package/pqueue
- garrisonj 11y agoYou could use a heap. I use Data.set because it is in the standard libraries, and it's close enough.