CS2851 -- Lab 3: Roll Your Own DoublyLinkedQueue Class

Outcomes Addressed

  • have a thorough understanding of commonly used library data structures.

Overview

The Java Collections Framework provides only a Queue<E> interface but no classes that provide an actual implementation. (Well almost - there is a very basic AbstractQueue<E> class that provides a minimal implementation of the element() and remove() methods, but is otherwise essentially non-functional).

For this assignment, you will create an implementation of the Queue<E> interface in a class called DoublyLinkedQueue<E>. The UML class diagram for the related classes is shown below.

Procedure

Create a class called DoublyLinkedQueue<E> that implements the Queue<E> interface. Your class may not make use of any collection classes in the JCF such as ArrayList or LinkedList - you must implement the internal structure yourself. Internally, your class must store elements of the collection in a doubly linked list that you design and implement. Recall from the lectures that the elements within the linked list are objects of a nested Node<E> class. Re-read Chapter 7 of the textbook, and study the sample code from lecture to re-acquaint yourself with the internal structure of both singly and doubly linked lists. Again, you'll be implementing a doubly linked list, but use caution: the JCF implementation of the doubly linked list is rather complex, so it is suggested that you base your doubly linked list as an extension of the singly linked list sample code from lecture or the textbook.

Technical Note: In your research and review of existing code, you may run across an obscure feature of Java where you see that you can declare nested classes static. This does not mean all their methods are static, or that they cannot be instantiated - rather, it means you instantiate the inner classes independently of the main enclosing class. There is no associated outer class object. Such classes are often called nested static classes. Non-static inner class objects always have an associated outer class object.

Note that because Queue<E> extends Collection<E> (and Collection<E> extends Iterable<E>), your DoublyLinkedQueue<E> class must provide an implementation for all behavior (i.e., methods) inherited from Collection<E>, Iterable<E>, and Queue<E>. However, you should provide "dummy" implementations for all of the methods defined in the Collection<E> and Iterable<E> interfaces, i.e., the only methods that you should implement "for real" are those from the Queue<E>, for the remainder, your implementation should just throw an UnsupportedOperationException.

Interim Report (due 11:00pm, Friday of week 4 (10/3))

You must submit:

  • A completed UML class diagram (as a .gif or .png image) containing all attributes that you will need in your implementation of your DoublyLinkedQueue<E> class, as well as the complete nested Node<E> class (with all methods and attributes).
  • The DoublyLinkedQueue.java file containing the attributes and method declarations that you'll implement - including javadoc-style documentation for each method. You do not need to provide real implementations for the methods, just the declaration (which essentially documents your detailed design). Note that this implies that your code should compile without errors.

Note: Your final implementation must agree with this design and will constitute 25% of your grade.

You do not need to create an XML document for the interim report. Just submit the UML image as the report and the Java file as the supporting file.

In addition, you should indicate how much time you spend on this assignment in the FAST system. You are encouraged to log your activity as you work on the project. At a minimum, you should log all of the time spent during the first week before the due date given above.

Lab report (due 11:00pm, Friday of week 5 (10/10))

Here is a template file to use as a starting point for this report.

Your report should include:

  • If needed, an updated UML class diagram (in .gif or .png format)
  • Your reaction (a couple of paragraphs on what you learned and what you thought about while working on this assignment, including at least one thing that you discovered as a result of executing your test plan)
  • An analysis of the asymptotic time complexity for each method in the DoublyLinkedQueue class.
  • Results from a test program that calls each method at least once.
  • The Documented source code for your container class.

As with any report you submit, correct spelling and grammar are required. In addition, your report should be submitted electronically following the Electronic submission guidelines. (You may wish to consult the XML help video and/or sample report before submitting your report.) Be sure to keep copies of all your files, in case something gets lost.

If you have any questions, consult your professor.

Acknowledgment

This assignment was originally developed by Dr. Chris Taylor and Dr. Mark Hornick.

  • © 2001-2009 Dr. Christopher C. Taylor •
  • Office: L-343 •
  • Phone: 277-7339 •
  • npǝ˙ǝosɯ@ɹolʎɐʇ