Concepts tested by this program:

  • Exceptions

New concepts tested by this program

  • Generic Classes
  • Doubly Linked List
  • Ordered Doubly Linked List
  • Iterators
  • Comparators

Your assignment is to write a generic doubly-linked list class and a generic sorted doubly-linked list class that inherits from your generic doubly-linked class. There is no additional GUI required for this assignment. Your list classes will be tested with Junit tests.

BasicDoubleLinkedList class

This generic doubly-linked list relies on a head (reference to first element of the list) and tail (reference to the last element of the list). Both are set to null when the list is empty. Both point to the same element when there is only one element in the list. A node structure has only three fields: data and the prev and next references. The class must only define the following entities: an inner class Node, an inner class that implements ListIterator (for the iterator method), head and tail references and an integer representing the list size. However only the next(), hasNext(), previous() and hasPrevious() methods of the ListIterator that you are required to implement. The rest of the methods can throw the UnsupportedOperationException, such as:

public void remove() throws UnsupportedOperationException{
throw new UnsupportedOperationException();}

All the entities are defined as protected so they can be accessed by the subclass. Follow the Javadoc that is provided.

SortedDoubleLinkedList class

A generic sorted doubly-linked list constructed using a provided Comparator. It extends BasicDoubleLinkedList class. Follow the Javadoc that is provided.

Exception Handling

UnsupportedOperationException this exception is a Java library exception and will be returned by the addtoFront and addToEnd implementations of the SortedLinkedList class and by the remove method of the iterator.

NoSuchElementException this exception is a Java library exception and will be returned by the next function within the iterator class when there are no more elements in the linked list.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.