Lecture 22
Learning objectives
After this class, you should be able to:
- Define a heap.
- Given a sequence of insertions and DeleteMax or DeleteMin in a max or min heap, draw the resulting heap.
- Given a heap drawn as a tree, show its array representation.
- Given the array representation of a heap, draw it as a tree.
- Give the time complexity for insertion into a heap, and DeleteMax/Min on it.
- Determine the children and parent of a node, given its index in its array representation.
- Give applications of heaps.
Reading assignment
- Section 6.9, except sec 6.9.2.
Exercises and review questions
- Exercises and review questions on current lecture's material
- Draw the max heap corresponding to the following array:
16 14 10 8 7 9 3 2 4 1
.- Show the heap that results from inserting
11
into the heap above.- Show the heap that results from DeleteMax on the heap in question 1.
- Prove that the children of node
i
are2i+1
and2i+2
, where the root is node0
.- Questions on next lecture's material
- None.
Last modified: 27 Mar 2008