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.
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):
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.
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.)
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.
int deleteHead() throws ListException which deletes
the first element of the list.
int head() throws ListException which returns the first
element of the list.
int current() throws ListException which returns the
current element of the list.
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.
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Tue Nov 4 07:43:08 1997.
This page generated on Tue Nov 4 07:43:53 1997 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu