Lab 5

Doubly Linked Lists

February 17, 2005

Lab Partners

Everyone should work with one lab partner on this assignment. If you don't know anyone, Mike will help you find a partner. Submit one solution with both of your names on it.

Before Lab Begins

Create a BlueJ project named inlab5 and copy the following files into it: Driver.java, Name.java, Node.java, MyListInterface.java and SingleLinkedList.java. This is the code that we discussed in lecture on Wednesday, February 16th.

3 points: Convert the Singly Linked List into a Doubly Linked List

Change the Node class so that each node has two pointers: a next pointer and a previous pointer. Change any relevant already-coded methods in the SingleLinkedList class so that a doubly linked list is maintained. Don't worry that SingleLinkedList is now a bad name for this class! Run the driver to make sure that everything still works.

3 points: Code the printReverse method

Supply the missing code for the printReverse method located in the SingleLinkedList class. The method should take advantage of the previous pointer to be as efficient as possible. Run the driver to make sure that everything works as you expect it to.

4 points: Code the insert method

Supply the missing code for the overloaded insert method located in the SingleLinkedList class. This method should maintain the list in ascending order using the last name as the primary key and the first name as the secondary key. Do NOT worry about duplicate names being inserted into the linked list.

If Time Remains

Utilize any remaining time to work on Program 2. Feel free to get assistance from either Mike or the consultants.

What to Submit

E-mail your code to Mike Thiesen at mthiesen@gmail.com in one message. The subject of the message should be: CS221-xx inlab5 your-names. The xx is the number of your lab section.

Before Lab Ends

Delete any BlueJ projects that you created and empty the recycle bin. Thanks.