Due date: Feb 12, 2007

Your goal in this project is to implement two data structures that implement a list interface. "List" is abstract data type and the two data structures are "linked list" and "array list". Both the data structures and should allow arrays of arbitrary length.

Here is the interface you must implement:

public interface List245 {
    /** Add the value to the end of the list. Allow duplicates, but do not
     *  allow null values.
     *  Throw IllegalArgumentException if value==null.
    public void add(Object value);

    /** Return value's position in a list, 0..n-1.  That is, first position
     *  is 0.  Return -1 if value is not found.
     *  Throw IllegalArgumentException if value==null.
    public int getIndexOf(Object value);

    /** Using recursion not a loop, return true if value is a member of
     *  the list else return false.
     *  Throw IllegalArgumentException if value==null.
    public boolean contains(Object value);

    /** Delete the first instance of value found in the list starting from
     *  the "left". In other words, remove the value added first upon
     *  duplicate entries.
     *  Throw IllegalArgumentException if value==null.
    public void delete(Object value);

    /** Return size of the list (not, for example, size of underlying
     *  array).  This is how many elements have been added to the list.
    public int size();

You must build two classes that implement this interface:

public class LinkedList245 implements List245 {...}
public class ArrayList245 implements List245 {...}

For your linked list class, I suggest you use a head and tail pointer.

For your array list, remember that the list must grow to any size (that fits within the memory of the computer). This means that if you try to add an element to the end of the array, you must allocate a bigger array, copy all the elements to the new array, and then add the new element to the end. This is called a "dynamic array" if you want to do a Google search.

Reminder: There are millions of implementations of these data structures out on the web. You are required to implement your own versions without cutting and pasting code from other people or any other source. You may discuss the project with your classmates, but you must not work together on a project. This includes not sitting next to each other in the lab and looking at each other's screens.

Project deliverables

You must turn in implementations of the following classes:

Further, please include in your jar interface List245 from above.

Put the source and .class files into list.jar.

Do NOT use a Java package for this project.

For the mid-release, I need a print out of just your code.

For the final release of this project, I need your final printout of your code.


You will submit a jar file called list.jar containing source and *.class files (include List245) into the submit directory:


(Use Java 1.5 or lower to compile your classes). For example, I would submit my project as file:



We will run your program via

java -cp ".:/home/submit/cs245/userid/list.jar" parrtTestProgram

We will assign points as follows:

points what
10 mid-project release Wed Feb 7th
10 unit tests
10 LinkedList245.add
10 LinkedList245.getIndexOf
10 LinkedList245.contains (recursive!)
10 LinkedList245.delete
10 ArrayList245.add
10 ArrayList245.getIndexOf
10 ArrayList245.contains (recursive!)
10 ArrayList245.delete

For each 10 point method, we will assign 8 points to functionality and 2 points to style. Style includes how clean the code is, how well you comment, how good the method and variable names are, whether you have removed all your debugging print statements, removed commented-out dead code, etc...

5 points off if your jar is messed up or your classes or have wrong case etc... I.e., anything that prevents us from being able to run your library "out of the box".

Reminder: There is no such thing as a late project; late projects get a zero score. Projects are due the instant class starts at 9:40 a.m. and your jars must be in the submit directory.