This class supports (n = # items stored in priority queue)
| operation | worst case | average case |
|---|---|---|
| add | O(log n) | O(1) |
| peekMin | O(1) | O(1) |
| removeMin | O(log n) | O(log n) |
Implementation concepts borrowed from Mark Weiss; the basic idea is that the node whose index is k has children stored with indexes 2*k and 2*k+1 for left/right children, respectively. The root of the binary heap has index 1.
@author Owen Astrachan
| |
| |