CSE 131 Module 8: List Structures

Studio


Studio 8

Review studio procedures before starting.

Warmup


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. Review the studio prep material on doubly linked lists. Keep that material open on somebody's display for reference during the studio.
    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.
  3. If you want to load the workspace I developed during lecture, copy and paste this link into the SVN Explorer as a new URL, change the yourusername to something more appropriate, and check it out.
    The code you should probably study is the SinglyLinkedListWithSentinel class, since it uses sentinels and so does this studio.
  4. Examine the provided IntList interface.
  5. Now let's start a new class in this package, DoublyLinkedListOfInts: You should now have stubs in your new class.
  6. 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.
  7. 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.
  8. For testing, I've included a TestLinkedListOfObjects jUnit test you can use as-is to test your code. 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.
  9. 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.
  10. Work on implementing the methods as we did in class, in the following order:

Submitting your work (read carefully)



Last modified 22:14:03 CST 11 November 2009 by Ron K. Cytron