Java data structure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pchahar
    New Member
    • Dec 2006
    • 9

    Java data structure

    I. Description

    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(Comparab le x) throws DuplicateItem
    public void delete(Comparab le 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.
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by pchahar
    I. Description

    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(Comparab le x) throws DuplicateItem
    public void delete(Comparab le 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.

    http://www.thescripts. com/forum/thread575307.ht ml


    All point to:



    Please make an attempt to do the problem, and post what you have tried, and the error messages you get, instead of just trying to get other people to do your work for you. (You will get much more help that way)

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by pchahar
      I. Description

      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(Comparab le x) throws DuplicateItem
      public void delete(Comparab le 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.
      And when you post what you'll have done, remember to use the code tags

      Comment

      Working...