Data Structures Homework 6, Fall 1999

Due: Mon, Nov. 15, 12 PM using turnin

Absolutely no late submissions accepted since solutions will be posted soon after the deadline.

In this project, you will implement a hash table and use it for your checked list (instead of the AVL tree used in HW5). Construct a concrete class, HashDictionary, which implements the following interface:
public interface LocatorDictionary {
 public int size();
 public boolean isEmpty();
 public Locator find(Object k); // Return locator for item (k',e) w/ k=k'
 public Locator insert(Object k, Object o); // Insert (k,o), get back locator
 public Object remove(Locator l); // Remove item at locator l
}
Your class should have a constructor that accepts a Comparator object and builds an initially-empty hash table. Use the comparator object from last assignment.

Use the rest of the classes from the solution to the previous homework for implementing and testing solution to this homework.
To compute the integer key for the hash table, transform the 4 x 4 board array to an integer as follows:

        key <- 0
        for i <- 0 to 3
              for j <- 0 to 3
                   key += Board[i][j] * (i*4 + j)
i.e., unroll the 2-D array into a 1-D array and multiply the tile number by its location and keep a running sum.

For your hash table, use double hashing .. The hash functions are..

h(x) = x % M

g(x) = (x / M) % M