https://github.com/esote/minmaxheap
Min-max heap for logarithmic-time removal of minimum and maximum elements.
https://github.com/esote/minmaxheap
heap min-max-heap
Last synced: 6 months ago
JSON representation
Min-max heap for logarithmic-time removal of minimum and maximum elements.
- Host: GitHub
- URL: https://github.com/esote/minmaxheap
- Owner: esote
- License: cc0-1.0
- Created: 2020-12-06T22:41:29.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-03-07T02:11:37.000Z (over 4 years ago)
- Last Synced: 2023-09-27T13:27:20.098Z (almost 3 years ago)
- Topics: heap, min-max-heap
- Language: Go
- Homepage: https://pkg.go.dev/github.com/esote/minmaxheap
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# minmaxheap [](https://pkg.go.dev/github.com/esote/minmaxheap) [](https://goreportcard.com/report/github.com/esote/minmaxheap)
Min-max heap operations for any type that implements heap.Interface. A min-max
heap can be used to implement a double-ended priority queue.
Min-max heap implementation from the 1986 paper "Min-Max Heaps and Generalized
Priority Queues" by Atkinson et. al. https://doi.org/10.1145/6617.6621.
| Operation | min-max heap | heap |
| --- | --- | --- |
| Init | O(n) | O(n) |
| Push | O(log n) | O(log n) |
| Pop | O(log n) | O(log n) |
| PopMax | **O(log n)** | O(n) |
| Fix | O(log n) | O(log n) |