Lecture 6
Learning objectives
After this class, you should be able to:
- Declare a vector class and use its following features: back, begin, empty, erase, front, insert, [ ], pop_back, push_back, rbegin, rend, constructors.
- Explain the semantics of insertion into a vectors whose current storage is already full.
Reading assignment
- Sections 3.1-3.4, class notes for complexity analysis.
- Lecture: Vectors.
- Page 84.
Exercises and review questions
- Exercises and review questions on current lecture's material
- Read the
Lec6/usevec.cpp
code and predict its output. Compare it with the output you get when you run the code.
- Replace
erase
in the file usevec.cpp
with pop_back
.
- Instead of doubling the capacity during push_backs, when size becomes equal to capacity, let us increase the capacity by 10. What is the amortized time complexity per
push_back
?
- Instead of doubling the capacity during push_backs, when size becomes equal to capacity, let us make it three times the previous capacity.What is the amortized time complexity per
push_back
?
- Questions on next lecture's material
- Explain the operations on the STL
list
in the vlm.cpp
from lecture 4.
Last modified: 11 Sep 2011