Heaps and PQs
Priority Queue Interface
/** (Min) Priority Queue: Allowing tracking and removal of
* the smallest item in a priority queue. */
public interface MinPQ<Item> {
/** Adds the item to the priority queue. */
public void add(Item x);
/** Returns the smallest item in the priority queue. */
public Item getSmallest();
/** Removes the smallest item from the priority queue. */
public Item removeSmallest();
/** Returns the size of the priority queue. */
public int size();
}Tree Representation
Approach 1a, 1b, and 1c



Approach 2

Approach 3

Implementation
Heap Structure

Heap Operations
Runtime
Last updated