You are to create a red-black tree which supports only the operations listed below. All operations should have time complexity O(log n) when there are n items in the tree, this is the guarantee that red-black trees give. The class should be derived from the TreeMap class in java.util.
The only operations which this class supports are:
public boolean is Empty()
public void makeEmpty()
public void insert(Comparable x) throws DuplicateItem
public void delete(Comparable x) throws ItemNotFound
public void deleteMin() throws ItemNotFound
public void deleteMax() throws ItemNotFound
public Object find(Comparable x) throws ItemNotFound
public Object findMin() throws ItemNotFound
public Object findMax() throws ItemNotFound
Your class should be named RBTree
II. Notes
In no particular order
• TreeMap expects Object and the requirement for RBTree is Comparable
• TreeMap doesn’t throw any reasonable checked exceptions. Your RBTree class does.
• TreeMap expects to perform a mapping of keys to data. RBTree doesn’t. You may find this to present a problem if you’re not careful in the way you implement some of the methods.
• The methods in the above list are the only methods that RBTree supports.
2006-12-15
08:20:56
·
3 answers
·
asked by
Pushpendra C
1
in
Computers & Internet
➔ Programming & Design