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.
  1. 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.
  2. Sort vi by name.
  3. Sort vi by iid.
  4. Sort vi by value; print it in order of decreasing value (i.e., largest value first).
  5. Insert Item("horse shoe",99,12.34) and Item("Canon S400",9988,499.95).
  6. Remove (erase) two Items identified by name from vi.
  7. Remove (erase) two Items identified by iid from vi.
  8. Repeat the exercise with list< Item> rather than a vector< Item>.