In this project, you will implement a locator-based dictionary ADT using skip lists. Construct a concrete class, SkipListDictionary, 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
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 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. Your applet should be similar in functionality to the applet used for the sequence ADT (but with much fewer buttons), in that it should allow users to input a key and get back a locator name, which can then be used for future remove or replacement operations.
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).