You will do this exercise by yourself, but be quick to ask questions of your instructor, student assistants, and classmates as desired.
sll.LinkedList
class, including methods in the LinkedListIterator
inner class, is worth 10 points. LinkedList.add(T x)
in class with you, so no points will be awarded for this method.The methods are already reasonably documented -- the provided Javadoc comments describe the behavior of each method (note that as is sometime the case, the documentation is in the interfaces like ListIterator.java and List.java). Be sure to ask questions of your instructor if the documentation is not clear. You do not need to add additional documentation to the methods of LinkedList.
Checkout the SinglyLinkedList
project from your individual SVN repository. SinglyLinkedList.sll
contains several Interfaces that support the implementation of a singly linked list. All your implementation should be done in the sll.LinkedList
class.
This project is modeled after the LinkedList
implementation in the Java.util package. You may wish to skim through that page to familiarize yourself with how Java's LinkedList
class is implemented.
It should be noted that this linked list implementation uses two nodes, first
and last
, that facilitates navigation of the list. first
represents the first node (or head) of the list and last
represents the last node of the list (or tail). A list is empty if both first
and last
equal null. A list has a single element if both first
and last
are equal to that element.
If you have questions, consider posting to Piazza (just be sure not to reveal any solutions there) --- instructors and other students can answer your questions there. You can also visit 217 during lab hours or stop by your instructor's office to get help.
jUnit tests for all the methods are provided in sll.LinkedListTest
. You might want to run these tests on your code to ensure your solution works as expected. However, the unit tests are not designed to be exhaustive - your code has to be correct for all inputs, even ones not specified in the unit tests.
Commit your project to your individual repository when you are done.