COP 4531: Lecture 17
Learning objectives
After this class, you should be able to:
- Given a set of activities, their start times, and their end times, give an optimal solution to the activity selection problem.
- Given a set of characters and their frequencies, construct the Huffman tree and determine the Huffman code for each character.
- Given a problem, give an optimal substructure property, prove this property, construct a greedy algorithm, prove its correctness and optimality, and derive the time complexity of your algorithm.
- Given a greedy strategy, give a counterexample to show that it is not optimal.
Reading assignment
- CLR: Sections 16.1 - 16.3.
- Review amortized analysis of vector inserts from COP 4530.
Exercises and review questions
- Questions on current lecture's material
- None.
- Questions on next lecture's material
- Give the amortized time required for n push_back operations on a vector, assuming that the size of the vector is increased by a factor of 3 each time it needs to be resized. Assume that the starting size of the vector is 1, and that increasing the size of a vector from m to p takes time p.