A Binary Heap is a common way to implement a Priority Queue.
This is because:
- It has easy access to the root node which can be the
minormaxdepending on implementation - Heaps are usually implemented as an array, which guarantees cache friendliness
- It is easy to
insert,searchanddeleteinside of cheaply, in worst case
Implementation
A min binary heap is an array as follows:

| 0 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| 1 | 3 | 6 | 5 | 9 | 8 |