Lecture 28
Learning objectives
After this class, you should be able to:
- Define a heap.
- Given a sequence of insertions into a 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.
- Determine the children and parent of a node, given its index in its array representation.
- Give applications of heaps.
- Explain why data structures that we have studied earlier are not ideal for implementing a priority queue.
Reading assignment
- Section 6, up to section 6.3.3.
- Lecture: Priority queues.
Exercises and review questions
- Exercises and review questions on current lecture's material
- Draw the pointer representation of a max heap whose array representation is as follows:
16 14 10 8 7 9 3 2 4 1
.- Show the heap that results from inserting
11
into the heap above.- 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: 4 Nov 2013