42G. Summary

A heap is a data structure that can be used for an efficient implementation of a priority queue. A heap can implement a priority queue so that inserting or deleting take time O(log(n), where n is the number of keys in the priority queue.

We use the data representation idea twice: we represent a priority queue as a heap (a kind of binary tree), and then we represent a heap as an array.

Insertion into a priority queue is based on a heap operation called reheapUp. Deletion from a priority queue uses heap operation reheapDown.