Starting from:

$30

Implementing Java Collections (LinkedLists)

Assignment (20 marks)
Focus: Implementing Java Collections (LinkedLists)
In this assignment, you will convert the MyLinkedList class, which we created in class, to a doubly
linked list. You need to do the following:
- Download the attached classes (MyLinkedList.java and TestMyDoublyLinkedList.java) and add them
to your project in Eclipse. Fix the package statement in each class to refer to your current package.
- Rename MyLinkedList class to MyDoublyLinkedList (see “Useful Eclipse Shortcuts” below).
- At this point, Eclipse should show no syntax errors.
- Add or change the code in MyDoublyLinkedList so as to convert it to a doubly linked list. That
is, you need to have and use two references for each node: next, pointing to the next node, and
previous, pointing to the previous node. Comments are added to MyDoublyLinkedList
beside the parts that need to be changed. Whenever you make a change, make sure that next and
previous properly point to the correct nodes or to null.
- Some comments ask you to improve the performance of your code using previous. Here, you have
to think about how the performance can be improved knowing that each node points to both the next
and the previous nodes. For example, if you want to get a reference to the second-to-last node, you
would only need to use tail.previous instead of having to traverse the list from head up to the
node at size-2 in case of singly linked lists.
- To improve the readability and maintainability of your code, try to use helper methods whenever
appropriate. A method that you have to create is getNodeAt(int index) which returns a
reference to a node at a given index. Again, you have to try to improve the performance of this method
given that you have both next and previous.
- Testing: Use the TestMyDoublyLinkedList class to test your code. You should have an output
similar to the one in the next page.
Test Output:
Grading:
See the comments in the given Java file for detailed breakdown of the mark.
Submission Instructions
For this assignment, you need to do the following:
1- Create a Java project of which name consists of your student number followed by the
assignment number, e.g., “1234567_A8”.
2- Create one class for each question and write your answer inside that class. Your classes
should have the same name as the question number (e.g., Q1)
3- After solving all questions, open Windows Explorer (or any other file explorer).
4- Navigate to your Java project folder (can be found inside your Eclipse workspace folder).
5- Locate the “src” folder for this project (the folder that includes the source code for all
questions).
6- Zip the “src” folder and rename the zipped file to match your project name (e.g.,
1234567_A8.zip).
7- Submit the zipped file to Canvas.
Note that you can resubmit an assignment, but the new submission overwrites the old
submission and receives a new timestamp.

More products