CSE 131 (Fall 2008)
Studio 8

If necessary, review studio procedures before starting. Work in groups of 2-3 people. I really mean it! No more than 3 people per group please.

Doubly Linked Lists

In lecture this week, we implemented an IntList interface using lists with one link per item. In this studio, you will investigate implementation of our IntList ADT using a doubly linked list. Your work will include design and implementation of iterators (forwards and backwards) for the list, and a discussion that compares your implementation with the singly linked list from lecture.
Here are the steps:
  1. Gather your group around one workstation. Plan on taking turns at the keyboard.
  2. Make a new Java project called studio8 in an eclipse workspace. Be sure to check the box to put source and compiled files in the same folder.
  3. Use the Import...General archive file steps to import this zip, which contains the interface and class stubs you will implement in a packge called lists.
  4. Review the studio prep material on doubly linked lists.
    Note: The "null" in the sentinel nodes should really be "any integer you like because it will be ignored". In other words, the sentinels should also be ListItem objects.
  5. Examine the IntList interface provided in the zip you installed.
  6. Now let's start a new class in this package, DoublyLinkedListOfInts: You should now have stubs in your new class.
  7. For each method in the interface, discuss an implementation and sketch how it would work.
    Look for opportunities to reduce one method's work to another's.
  8. One of the most important aspects of this design is the use of a sentinel, as depicted in the studio prep material . Discuss the role of sentinels and how they affect (simplify) your implementation.
  9. For testing, I've included a TestLinkedListOfObjects jUnit test you can use or adapt to your new class, by editing it or copying it into a new jUnit test. Notice the declarations of the interface type (IntList) as compared with the actual objects instantiated (LinkeListOfInts).
    Use the interface type as much as possible. It does not commit to an implementation and this makes it easier to change from one implementation of the interface to another.
  10. The ListItem class, as given to you and as used in lecture, had only one pointer, namely next. For the doubly linked list, you need to augment ListItem to have two pointers: next and prev.
  11. Work on implementing the methods as we did in class, in the following order:

Last modified 14:29:47 CDT 21 October 2008 by Ron K. Cytron