{Assignment Five: Lists} * Assigned: Monday, October 27, 1997
* Suggested due date: Friday, October 31, 1997
* Due: 4pm, Monday, November 3, 1997 Summary: In this assignment, you will implement singly linked lists using arrays. Note: I'd recommend you get this done by Thursday, October 30, since support is generally available on Tuesday and Wednesday and the next assignment will be due the following Thursday. However, I have given you some extra time since it's post-break. Collaboration: You can work on this assignment in groups of up to size three. You may discuss your design with any size group. You may also work with each other on general debugging issues. If you work as part of a group, you are responsible for ensuring that all members of the group understand all sections of the assignment.

Assignment

Develop an array-based implementation of lists of integers, called IntList. Your implementation should include a "current" reference to the list. Your implementation should support the following routines (and they should have the same names): * Two constructors: + IntList() that creates a list with some reasonable default maximum size. + IntList(int maxsize) that creates a list that can hold up to maxsize elements. * Three ways to manipulate the current pointer. + void advanceCurrent() throws ListException which advances the current pointer + void resetCurrent() throws ListException which resets the current pointer to the front of the list. + boolean find(int elt) throws ListException which advances the current pointer to the first element that matches the given element. It returns true if the element is found, and false otherwise. (Note that you'll need to specify where the current pointer ends up if the element isn't found.) * Three ways to insert elements: + void insertAtHead(int val) throws ListException which inserts an element at the head (front) of the list. It should throw an execption when it is impossible to do the insertion (e.g., when the list is full). + void appendAtEnd(int val) throws ListException which appends an element at the end of the list. It should throw an exception when it is impossible to append the element. + void replaceCurrent(int val) throws ListException which replaces the current element of the list. * One way to remove elements: + int deleteHead() throws ListException which deletes the first element of the list. * Two ways to retrieve elements: + int head() throws ListException which returns the first element of the list. + int current() throws ListException which returns the current element of the list. * A few utility functions: + int size() which returns the size of the list. + int capacity() which returns the capacity of the list. + int min() throws ListException which returns the smallest element of the list. + int max() throws ListException which returns the largest element of the list. Note that you will need to define your own ListException class (and perhaps subclasses of that class). You should also develop an appropriate test suite for your class.