Notes for week 8 lecture on the heap implementation of priority queues (ODS chapter 10)

----[ Mon, Apr 7 ]----

The (min) Priority Queue interface (it was introduced in chapter 1):

How to implement priority queues? Let's try a couple of ideas. Let n be the current size of the priority queue.

A heap has 3 key properties.

  1. It is a left-complete binary tree.
  2. It is a binary tree with the heap property: Value at a node is less than (or equal to) the values at it's children (if any).
  3. It's storage is an array. We exploit two views: as binary tree, as array.

Illustration, ODS Chapter 10
Implementation: BinaryHeap.h. Another example.