CSci 121 Lab 5: Simple Linked Lists
Objectives
There is not much to do in this lab beyond
playing with the linked list class we have been discussing
in class for the past couple of days, and to see if you can
write a couple of methods for removing list elements.
Exercises
- You will want to start by downloading
SimpleIntNode.java,
SimpleIntLinkedList.java,
LLApplet.java,
and
LLApplet.html.
As in Lab 4, the latter will (I hope) cause the applet to run
that tests some of the features of SimpleIntLinkedList.
Try all the buttons, examine the lists you get, and try to understand what is
happening in terms of the underlying data structure.
- First exercise of the day: Add a
removeFirst() method to SimpleIntLinkedList.
It should have no parameters, and should remove the first element of the list AND return the value
stored in it.
- Second exercise of the day:
put in a
remove() method similar to the
"iterator" add method, that removes the node after
the current one (and returns its values).
- Add buttons to
LLApplet.java for testing the remove
methods. Try them out.
- Hand in a printout of any of the code you modify.
SimpleIntNode.java should remain untouched.
Last modified: 2/27/07 by Frederic Green.