Pointers and Linked Lists

advertisement
Assignment 6 - Pointers and Linked Lists
Page 1
CIS 501
Spring 2003
Assignment Number 05 - Pointers and Linked Lists
Reading: Complete the reading required for Part E of the course Syllabus.
Programming: An individual assignment.
Part A:
Do the following Exercises at the end of Chapter 7 of the Headington and Riley text -==> 7.1, 7.3 and 7.5.
Do the following Exercises at the end of Chapter 8 of the Headington and Riley text -==> 8.2 and 8.3
Part B:
Write the program requested in Programming Project 8.4 of the H & R text. For the first part of the
requested Output (first paragraph of the section entitled OUTPUT, you are expected to maintain the list of
attendees as a singly linked list (named SLL for the purposes of this discussion), ordered by last name of
attendee. Test your program using data that you have made up.
The output requested in the second paragraph of the OUTPUT section is more difficult to achieve. You
should be reasonably clever in choosing an approach to generating the required state-by-state listing. (Note
that this listing does not have to be ordered in anyway -- just grouped by state). We will assume the
conference in question is being held back when there were only 13 states in the union. (Can you name the
original 13 states?)
For this part of the problem, you should first make a copy of the singly linked list you created initially,
making sure that each node in your new list (which we will refer to as a multi-linked list, MLL) has room
for a link used to tie nodes together in lists organized by state. Thus your nodes will be tied together in 13
different lists. Each node will be in exactly one of these lists. (Where will you put the header pointers for
each of these lists? Perhaps in a lookup table?)
We want all parts of your program to run reasonably efficiently. Be sure to provide an English description
(no more than one page double-spaced) outlining the approach you used in generating the state list.
Hints:
You should design the system for solving this problem around the primary data to be manipulated. For
each of the primary data elements, you should build a class implementing the required data stores and the
required operations on these stores:
 A lookup or search table containing two-letter state codes, full state names, and pointers to the
head node for the linked list of attendees for that state.
 The input file.
 The singly-linked list used for storing the data.
 The multi-linked list used for storing the data linked by state.
Assignment 6 - Pointers and Linked Lists
Page 2
Among other things, you will be graded on
1) How well you selected your test data to test all possible paths through each of the functions you
write in your program and your classes (you will want to analyze the code for each function and
be sure that your test data exercises all paths in each function).
2) How neatly and concisely you comment your classes, methods, and attributes.
Turn in: (I will provide the due dates in class)
Part A: Homework exercises as assigned.
Part B: The program (with three classes) that will produce the first part of the required output list (you
do not need the multi-linked list class for this part).
Part C: The program with the fourth class added (the multi-linked list class) to produce the attendees by
state.
For Parts B and C, turn in
 A copy of the class descriptions (data stores, functions (with purpose, return value, and arguments
fully described, and a picture) for each of the above classes.
 Your test data and a final working program.
 Copies of your test drivers (2 of them) and a copy of the output from the tests of these programs.
Download