CMPU-203: Introduction to Computer Science III

Quiz #5

Note: I will be out of town this week. This quiz is to be done in class as a group. A designee should sumbit the final answers to me by email. See the email message I sent to each student.
  1. From the hierarchy of concepts we have developed so far (see concept hierarchy), under what concepts would Associative Container appear?

  2. An associative container requires a specific operation be provided for keys. What is that operation?

  3. A sorted associative container requires an additional operation be provided for keys. What is it?

  4. What is a container operation for which sets are particularly well suited?

  5. Read carefully the definition of a stack. What is wrong with the following code:
      stack<int> s;
      stack<int>::iterator i;
    
      s.push(8);
      s.push(7);
      s.push(4);
    
      for(i=s.begin(); i!=s.end(); i++)
        cout << *i;
    

  6. Think of some real life examples of things that operate as a stack, as a queue, and as a priority queue. Your examples do not have to be related to computers, but they can be. You should have several examples of each.

  7. What is the difference between a priority queue and a set in STL?

  8. Write program that reads in a bunch of names (strings) and id numbers (also strings). When the names and ids are all read in (use a special input string to indicate the end of names), the program will propmpt for id numbers and print out the associated name. Decide the best container to use to store the names and ids and use it in the program.