CS 51 Homework Laboratory # 12
Circular Doubly-Linked List
Objective: To gain experience with linked lists.
Not having to keep track of both the head and tail of the list will simplify much of the code. In particular removeLast and addLast no longer must update the tail instance variable.
For this assignment I have provided a starter that includes most of the methods. You need only write the following methods of class CircularDoublyLinkedList:
You will find that if you think about it you can write removeFirst by using the already provided method removeLast and one more line of code. Similarly, addLast can use the method addFirst. (Do not copy the code in these methods, call them directly in your method bodies. If you do write these properly, each of these two methods requires only 2 lines of code.)
The last two will be more complex. However, their bodies share some similarities with the code provided in set(i,newValue).
The program TestLinkedList will pop up a window that illustrates snapshots of the list at certain points. In the text area below is printed other information, including descriptions of the graphics of the lists that should help you see if your code works.
When your work is complete you should deposit in the dropoff folder a copy of your folder. Before you do this, make sure the folder name includes the phrase "Lab 12" and your name. Also make sure to double check your work for correctness, organization and style. This assignment is due Thursday evening, though you will likely be able to finish it during the lab and then go on to work on your test program.
Grading Point AllocationsValue | Feature |
Syntax Style (3 pts total) | |
1 pt. | Descriptive comments |
1/2 pt. | Good names |
1 pt. | Good use of constants |
1/2 pt. | Appropriate formatting |
Code quality (3 pts total) | |
1 pt. | conditionals and loops |
1 pt. | General correctness/design/efficiency issues |
1 pts. | Parameters, variables, and scoping |
Correctness (4 pts total) | |
1 pt. | removeFirst |
1 pt. | addLast |
1 pt. | get(i) |
1 pt. | add(i,value) |
Computer Science
051
Department of Math & Computer Science
Pomona College