CS 2005, B Term 1999
Techniques of Programming
Lab 3 (Nov. 17)

In this lab session you will implement the member functions for a List class similar to (but simpler than) the List class of HW3. This should provide practice in linked list manipulation, which should prove to be helpful in completing HW3.

  1. Sign in with the TA. You should both print your name and sign the sheet.
  2. Listen to the TA's mini-lecture.
  3. Log onto your CCC Unix account and change the directory to /cs/cs2005/samples/lab3/. That directory contains the following files for a class named List:
  4. Do the problems listed below. Feel free to ask the TA questions about the problems. Actively working on the lab assignment during the lab session is required. Don't worry if you can't finish the full assignment before the lab session is over. You can finish afterwards.


  1. Copy the files in /cs/cs2005/samples/lab3/ to one of your own personal directories. Study the header file minilist.h. This file defines a class named List similar to that used in HW3, but without the insert(), attach(), and remove() member functions. However, a new modification member function named grow() is included in the Lab3 version of the List class. Study the private member variables included in the class definition.

  2. Examine the incomplete implementation file minilist.cxx. Some of the member functions of the List class have already been implemented there. Fill in the implementation of the start() member function in minilist.cxx in a way that is consistent with the specification provided in the header file. Note that start() must initialize two of the private member variables of the List class.

  3. Implement the advance() member function in minilist.cxx so that its specification in the header file is satisfied. Again, you must ensure that the private member variables of the List class are updated in the appropriate way.

  4. Implement the grow() member function in minilist.cxx. This function should behave as specified in the header file. Make sure that your implementation works correctly in all cases. In particular, consider the case of a list that is initially empty.

  5. Type make at the Unix prompt in the directory to which you copied the files provided in /cs/cs2005/samples/lab3/. This compiles the linked list toolkit, compiles the List class definition, compiles the test program, links the appropriate files, and produces an executable file named minilisttest. Run the executable file minilisttest and use it to debug your implementation. Does the size() function return the values one would expect after the grow() function is invoked? How about the is_item() and current() functions? Try invoking the member functions in different orders to make sure that they're behaving as expected in all possible situations. Modify your implementations as needed.

  6. Use any remaining time to work on HW3.