CMSC132 Summer 2017
Doubly Linked Lists
Due Date: July 3, 2016 11:59pm
Assignment Type: Closed (See
Policy)
Overview
For this project you will implement a basic doubly linked and a sorted doubly linked list.
Notice that no public tests are part of this project as all tests are either
release or secret.
Objectives
This project will allow you practice doubly linked lists and testing.
Grading
- (40%) Release Tests
- (50%) Secret Tests
- (10%) Style
Clarifications
Any clarifications or corrections associated with this project will be
available at Project
Clarifications.
Code Distribution
The project's code distribution is available by checking out the project
named LinkedListsProject. The code distribution provides you with the following:
- listClasses package → Where classes implementing linked lists will appear.
- tests package → Where you should place your student tests.
Specifications
- You are expected to implement two classes: BasicDoubleLinkedList and SortedDoubleLinkedList.The javadoc describing
what you need to implement can be found at
Project Javadoc.
-
The linked list in our project has a head and tail reference.
The next link of the last node points to null.
-
Methods addToEnd(), getLast(), retrieveLastElement() rely
(and must use) the tail reference.
-
The head and tail must be set correctly when list operations
update the list.
-
Your code must be efficient. For example, you will lose credit if
you perform an unnecessary list traversal(s) during the implementation
of a method. Keep in mind this is a doubly linked list.
-
If you see in the submit server the error "missing_component", the problem is that you
are missing a required class. You can also get this error if you are not defining a generic
class correctly. For example, your SortedLinkedList class is not being defined as expected.
It is recommended that you try submitting your project immediately (if you have not done
so yet) so you can identify this problem (your code may work in Eclipse but not in the submit server).
Requirements
- You may not use recursion in this project.
- For this project you are not required to write student tests, but you are strongly
encourage to do so. If you have a problem with your code and need assistance during
office hours, you need to have a student test(s) that illustrates the problem you are
experiencing. See Student Tests
for information regarding the implementation of student tests.
-
The iterator you define may NOT be used to implement other list operations (e.g., add).
The iterator is for users that want to iterate over the list.
-
You need to implement a doubly-linked list that relies on a head and tail reference.
- See Style
Guidelines for information regarding style.
Sample Driver
The following driver and associated output provide an idea of the classes you need
to implement.
package tests;
import listClasses.BasicDoubleLinkedList;
import listClasses.SortedDoubleLinkedList;
public class SampleDriver {
public static void main(String[] args) {
BasicDoubleLinkedList < String > basicList = new BasicDoubleLinkedList();
basicList.addToEnd("Red").addToFront("Yellow").addToFront("Blue");
System.out.println("First: " + basicList.getFirst());
System.out.println("Last: " + basicList.getLast());
System.out.println("Size: " + basicList.getSize());
System.out.println("Retrieve First: " + basicList.retrieveFirstElement());
System.out.println("Retrieve Last: " + basicList.retrieveLastElement());
System.out.println("Removing Red");
basicList.remove("Red", String.CASE_INSENSITIVE_ORDER);
System.out.print("Iteration: ");
for (String entry : basicList) {
System.out.print(entry + " ");
}
SortedDoubleLinkedList sortedList = new SortedDoubleLinkedList(String.CASE_INSENSITIVE_ORDER);
sortedList.add("Yellow").add("Red");
System.out.print("\n\nIteration (for sorted list): ");
for (String entry : sortedList) {
System.out.print(entry + " ");
}
sortedList.remove("Red");
System.out.print("\nAfter remove in sorted list first is: ");
System.out.println(sortedList.getFirst());
}
}
Output
First: Blue
Last: Red
Size: 3
Retrieve First: Blue
Retrieve Last: Red
Removing Red
Iteration: Yellow
Iteration (for sorted list): Red Yellow
After remove in sorted list first is: Yellow