Skip to content
/ heap Public

An immutable Heap (priority queue) implementation in Scala

Notifications You must be signed in to change notification settings

cb372/heap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

An immutable Heap (a.k.a. Priority Queue) implementation.

Benefits over scala.collection.mutable.PriorityQueue:

  • Supports decreaseKey operation for efficiently decreasing the key associated with a given value. Useful in e.g. Dijsktra's shortest path algorithm, Prim's minimum spanning tree algorithm.

  • extractMin returns an Option. Specifically, in the case where the heap is empty, it returns None rather than throwing an exception.

  • Immutable. (Uses a Vector and a Map to hold its internal state.)

Performance

  • extractMin = O(log(n))
  • insert = O(log(n))
  • decreaseKey = O(log(n))

About

An immutable Heap (priority queue) implementation in Scala

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages