YCP Logo Lab 21: Singly-linked lists

Due: Monday, Dec 8th by 11:59 PM

Getting Started

Import CS201_Lab21.zip (File->Import...->General->Existing Projects into Workspace->Archive File). You should see a project called CS201_Lab21 in the Package Explorer.

Your Task

The starting code contains a partially-complete implementation of a LinkedList class. Your task is to complete the size, add, get, set, and remove methods. The behavior of these methods should be the usual behavior for list classes:

  • size returns the number of elements in the list
  • add adds an element to the end of the list
  • get gets the element value at a particular index
  • set sets (modifies) the element value at a particular index
  • remove removes the element value at a particular index

A JUnit test class, LinkedListTest, is provided.

Note that when you are done, the testIteratorRemove test will still fail. Implementing removal of an element of a linked list using an iterator is challenging.

Hints

The remove method should remove the node containing the selected element from the list.

For each method, sketch out an algorithm on paper before implementing it. Drawing diagrams, especially in the case where the list structure is being modified, is extremely helpful.

Submit

When you are done, save the project (CS201_Lab21) to a zip file by right-clicking it and choosing

Export...->Archive File

Upload the saved zip file to the Marmoset server as lab21. The server URL is

https://camel.ycp.edu:8443/