The TAO of Java


Laboratory: Doubly-Linked Lists

Summary: In this laboratory, you will have an opportunity to enhance your understanding of the list ADT through an implementation using doubly-linkeds.

Contents:

Required Code Files:


Exercises

Exercise 0: Preparation

a. You should already have a package named username.lists with a variety of files.

b. Add all of the files linked above in that package.

c. Make sure to change the package name in each file.

Exercise 1: Code Reading

a. Skim through DoublyLinkedSimpleList and confirm that you understand the implementation.

b. Using TestDLSimpleList, verify that it behaves as it should.

Exercise 2: Sequenced Lists

a. Sketch how you might write addToFront, addToEnd, addBefore, and addAfter.

b. Compare your implementations of addToEnd and addBefore to those in DoublyLinkedSequencedList.

c. Fix the implementations of addToFront and addAfter.

d. Test your work using TestDLSequencedList.

For Those With Extra Time

Figure out a way to add an isValid operation. One strategy is to have a counter in the primary class and a corresponding field in each cursor. When we change an element of the primary class, we increment the counter. When we create a cursor, we copy the counter. If the value stored in the cursor is smaller than the counter, the cursor is invalid.

History

Sunday, 27 November 2005 [Samuel A. Rebelsky]

Monday, 28 November 2005 [Samuel A. Rebelsky]

Tuesday, 29 November 2005 [Samuel A. Rebelsky]


This page was generated by Siteweaver on Tue Nov 29 11:26:37 2005.
The source to the page was last modified on Tue Nov 29 11:26:35 2005.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/TAO/Labs/doubly-linked-lists.html.

You may wish to validate this page's HTML ; Valid CSS! ; Check with Bobby

Samuel A. Rebelsky
rebelsky@grinnell.edu