top of page

Download the needed files, you should have 3 .java files, LLNode,
TestLinkedList and LinkedList.
You are required to complete the LinkedList class. This class is used as a linked
list that has many methods to perform operations on the linked list. To create a
linked list, create an object of this class and use the addFirst or addLast or
add(must be completed) to add nodes to this linked list(I created one linked list in
TestLinkedList). I’ve already created the class for you and have some completed
method in there, your job is to complete the empty methods.
For every method you have to complete, you are provided with a header, Do not
modify those headers(method name, return type or parameters). You have to
complete the body of the method.
public void add(T afterThis, T info)
The parameter info will be the information the new node should contain, and the
new node will be added after the node that contains the parameter afterThis as
an information.
public void removeFirst()
Removes the first node in the linked list. Hint: be aware of empty lists.
public void removeLast()
Removes the last node in the linked list. Hint: be aware of empty lists.
public int size()
returns the size of the linked list.
public boolean isEmpty()
returns true if the linked list is empty, otherwise returns false.
public boolean contains(T item)
returns true if the list contains a node with the same information as the
parameter of the method.
Test your method with TestLinkedList, complete one method at the time and
uncomment the method calls in the main method.
General Instructions:
- No hard copies will be collected.
- Do not send your files through the email!
- You should submit your work by the due date, No extensions will be given.
(See syllabus for late homework policy).
- DO NOT turn in multiple files, only one .zip file.
What to turn in:
There should be one .java files(, and on .pdf file, put all those files
into a zip file and name it <YourFirstName_YourLastName>.zip, submit the zip
file into the Dropbox on D2L.
How to zip multiple files?
On Windows: Select all the files > right click > Send to > Comprised File
On Mac: Select all the files > Click/Tap with two fingers > Compress Items

CS304, Data Structures Homework 3

    bottom of page