CPSC 221H-200: Data Structures & Algorithms
Lab Exercise #2
Spring 2009
Drill from "Programming: Principles and Practice in C++" by Bjarne Stroustrup pg 764
After each operation (as defined by a line of this drill) print the vector.
- Define a struct Item { string name; int idd; double value; /* ... */}; and make a vector< Item> vi, and fill it with ten items from a file.
- Sort vi by name.
- Sort vi by iid.
- Sort vi by value; print it in order of decreasing value (i.e., largest value first).
- Insert Item("horse shoe",99,12.34) and Item("Canon S400",9988,499.95).
- Remove (erase) two Items identified by name from vi.
- Remove (erase) two Items identified by iid from vi.
- Repeat the exercise with list< Item> rather than a vector< Item>.