Goals: This laboratory provides you with more experience using lists and pointers.
The previous lab filled in two parts of the program ~walker/c/lists/namelist.c In this lab, you are to fill in two more menu options.
Note: Do NOT go on to the next part until you have written a convincing answer to this question!
To perform this task, you first have to read in the name of the item desired. Then you need to search the list item-by-item to find the desired item. Next you need to remove that given item from its current place in the list (if it is not already first). Finally you need to insert that given item at the beginning of the list.
Since manipulation of lists is most efficient if only pointers are manipulated, your program should neither create new nodes nor dispose of existing ones. In particular, your program should not use either the malloc or free functions during the processing of putFirst.
Also, your program should respond appropriately in all cases. In particular, putFirst should print appropriate messages if either list is null or the item designated is not found on the list.
Work to turn in:
This document is available on the World Wide Web as
http://www.cs.grinnell.edu/~walker/courses/195.fa01/lab.lists2.html
|
created September 27, 2001 last revised September 27, 2001 |
|
| For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |