What is a heap?
A (maximum) heap is a complete binary tree having a key associated with each node, the key of each parent node being greater than or equal to the keys of its child nodes
What two operations does the heap ADT support?
insert new element and delete/retrieve maximum element
These both can be performed in O(log n) time.
What is the most common way to represent a heap?
In an array
Inserting a node into heap example

Deleting maximum node in a heap example

What is a priority queue?
A priority queue is a container for a totally-ordered set of elements (ADT)
What operations does a priority queue support?
insert, peek front, delete front, decrease key (i.e. priority of an element)
How is priority queue often implemented
Often is implemented using a binary heap data structure
What can priority queues be used to represent?
Particular kinds of stacks and queues.
The Selection Problem
(not very efficient O(n lg n) )
How do you create a selection algorithm that runs in Θ(n) for all input?
ensure that “good” pivots are found
median-of-medians linear-time algorithm
• The divide-and-conquer recursive M.-M. algorithm: