CS 307 University Extension - Fall 2001 - Assignment 6
ADTs and Linked Lists
Handed Out: November 5, 2001
Due: Before 11:59:59 p.m. Thursday, November 15, 2001
Purpose: To practice using ADTs and implement a linked data
structures
Provided classes: Hand.java, Card.java
Part 1 - Using ArrayList
For this assignment you will reimplement the Hand class using the an ArrayList from the Java standard library as the underlying storage container for the Cards instead of a native array of Card objects, Card[]. You will take the provided Hand class and make the necessary changes. You may make any changes you want as long as the public interface of the class does not change.
Part 2 - Linked Lists
Implement a LinkedList class with a doubly linked list. This is not a circular linked list. Use the following class for the nodes:
public class DoubleListNode
{ public Object data;
public DoubleListNode next;
public DoubleListNode prev;
}
Implement the following methods for the class. For each and every method state the Big O number of executions if there are already N items in the list. Also be sure to list pre and post conditions for each method.
public class LinkedList
{ // instance variables left up to you
public LinkedList()
public LinkedList(Object first)
public LinkedList(LinkedList)
public int size()
public boolean isEmpty()
public void makeEmpty()
public void addFront(Object val)
public void addBack(Object val)
public void removeFront()
public void removeBack()
public Object getFront()
public Object getBack()
public boolean contains(Object val)
public boolean remove(Object val)
// removes first instance of object
}
Email me you LinkedList.java and Hand.java files