|CSC 161||Grinnell College||Spring, 2010|
|Imperative Problem Solving and Data Structures|
This laboratory provides you with some experience using doubly-linked lists. The lab also highlights a process of incremental program development.
Recent labs (Scheme-Like Linked Lists and Singly-Linked Lists) presented the user with the following menu of options:
Options available I - Insert a name into the list D - Delete a name from the list C - Count the number of items on the list F - Move an item to the front of the list L - Print the last item on the list P - Print the names on the list R - Print the names in reverse order Q - Quit
The program then carried out the designated operations using a
singly-linked list. To be more specific, file
~walker/c/lists/namelist.c contained the menu-driven
main program for this work, as well as functions for the
insertion and deletion of a name, and printing the names. You then
added functions to count names, move an item to the front of the list, and
print names in other ways.
This lab asks you to rewrite the
namelist.c program, so that
it maintains the names on a doubly-linked list.
In your work, you should follow several main principles, including:
Applying these principles to the problem at hand, the approach will be to
take the program
namelist.c that you developed for
singly-linked lists and make the minimal changes necessary to implement a
namelist.cto a file
nodestructure, so each node has a
prevpointer to a previous node, as well as
nextfields. (For clarity, you may want to replace all occurrences of node by dnode.)
namelist.cto determine which ones require modification. Such modifications might arise for either of two reasons:
Identify which functions will require change according to one or both of these criteria.
To begin program revision, make changes (as needed) to
putFirstIn each case, work on only one function at a time, and complete its testing before moving to the next function.
This document is available on the World Wide Web as
created 27 September 2001
last revised 5 April 2010
|For more information, please contact Henry M. Walker at email@example.com.|