PriorityQueue: Tree Implementation
We are going to explore a tree-based implementation of PriorityQueue. This implementation is called a Binary Heap (or simply a Heap).
A heap has the following properties:
- Structure (shape) property: heap is a complete binary tree.
The structure property implies the height of the tree is $O(\lg n)$.
- Order (heap) property: the element stored at each node has a higher priority (is considered "better") than its children.
The order property implies the "best" element is always at the root.