English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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

3 answers

I forgot how to implement the balancing-rotation activity it is the key for the complexity, this is a 3rd year college stuff; I had nightmares that is pleasant compare to this.

However:
private void rotateLeft(Node pivot)
private void rotateRight(Node pivot)
are important.

2006-12-15 09:09:37 · answer #1 · answered by Andy T 7 · 0 0

If it is derived from the TreeMap, then just use the functions and methods that are given and nest them in the functions you need to create and add some extra features like the Exceptions you have.

2006-12-15 10:07:20 · answer #2 · answered by Anonymous · 0 0

there are a good type of issues presented to concepts once you want to create a programming language. before each and every thing please comprehend that it's not a one individual pastime. the first an accurate element you need to keep in concepts once you want to create a PL is the type of a compiler. that contain techniques like a million. Lexical diagnosis 2. Syntax diagnosis 3. Semantic diagnosis 4. Parsing 5. Intermediate Code era 6. Code optimization 7. truly code era 8. image table administration 9. The grouping of words into passes 10. Compiler structure procedures (those are various of steps in which a compiler is regularly occurring with a code language) then you ought to attraction to close each and each and every of the algorithms of grasping approach, dynamic programming and so on, that would want to help you in memory administration and problem fixing. For code era, you need to attraction to close assembly language, and intermediate code. initiate studying a textbook on ideas of programming languages and Compiler Designs and it truly is going to lead you to what you need to do next. each and each and every of the purely right :) wish this helps :)

2016-11-26 21:32:02 · answer #3 · answered by ? 4 · 0 0

fedest.com, questions and answers