Priority Queue. A Max Priority Queue (or PQ for short) is an ADT that supports at least the insert and delete-max operations. A MinPQ supports insert and delete-min.
Heap. A max (or min) heap is an array representation of a binary tree such that every node is larger (or smaller) than all of its children. This definition naturally applies recursively, i.e. a heap of height 5 is composed of two heaps of height 4 plus a parent.
Tree Representations. Know that there are many ways to represent a tree. Because heaps are complete trees, we prefer to use represent them with arrays. This leads to better real-world performance than using nodes. (More on this later.)
- [Textbook 2.4.21] Explain how to use a priority queue to implement the stack and queue data types.
- [Adapted from Textbook 2.4.27] Add a
min()method to a maximum-oriented PQ. Your implementation should use constant time and constant extra space.
- Design a data type that supports insert in O(log N) time, delete-the-max in O(log N) time, and delete-the-minimum in O(log N) time.
- Q3d from CSE 373 19au MT (Solution)
- Q2f from CSE 373 19au Final (Solution)
- Q8a, Q8c from CS 61B 16sp MT2 (Solution)
- Q2 from CS 61BL 19su MT2 (Solution)