In this project, you will implement a locator-based dictionary ADT using skip lists. Construct a concrete class, SkipListDictionary, which implements the following LocatorDictionary 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
public Object replaceKey(Locator l, Object k); // Replace key at locator l
public Object replaceElement(Locator l, Object k); // Replace element at locator l
}
Your class should have a constructor that
accepts a Comparator object and builds an initially-empty skip-list
dictionary.
Your locator should support the following Locator interface:
public interface Locator {
public Object key(); // Return the key for this locator
public Object element(); // Return the element for this locator
public Object containter(); // Return the container this locator is in
}
You will need to implement this interface with a concrete
class with a name like SkipListLocator.
A demonstration applet is now available, which you can use. This applet has a button for each dictionary operation and can be used for debugging purposes. Caveat: it uses the old-style Java event handling, which your compiler might not like. Also, the final project will be graded with a tester program, not this applet. This tester should be available soon.
You'll will also need a Comparator interface and StringComparator class.
Note: To clarify, the skip list dictionary should dynamically adjust the number of skip lists (the number of levels in the structure) as elements are added and deleted. You want to keep the number of lists O(log n); Dr. Goodrich suggests m = 3 log n. He also says,
There are a number of heuristics that people use. One of the simpler ones says to increment the max level when an insertion tries to add an item to the top sequence (which should always be kept empty).
So, to summarize. You will need to supply the following: