Cramster.com - Homework Solutions, Lecture Notes, Exams, and Free Online Homework Help
Sign Up Now! Login Customer Support Cramster Blog
McAfee Secure sites help keep you safe from identity theft, credit card fraud, spyware, spam, viruses and online scams
Problem Solved.
    Home    
    Homework Help    
   Answer Board   
    Resources (Beta)    
   
Member's Topic Headline:

Trivial question?

Know the answer? Have a better solution? Share it.
Sign Up Now for FREE!
Join the thousands of students
getting ahead in their classes.
Member Testimonials

Question:

Advertisement:

Answer | Ask New Question | Customize Profile | Leaderboards | 
FAQ

Member's Avatar

Scholar
Karma Points: 200
Respect (83%):
Date Posted: 7/19/2008 8:09:13 PM  Status: Live
Trivial question?
Course Textbook Chapter Problem
Software Design Introduction to Algorithms (2nd) by Cormen, Rivest, Leiserson 13.3 5E
Question Details:
I don't quite understand the point of this question.
RB-INSERT is supposed to color the node inserted red.
Doesn't that means the second node inserted into the empty tree will be colored red? Wouldn't that conclude to prove pretty trivially? Or is there some complications to this question that I am missing?
Bonus Point Alert! Earn +2 additional karma points for helping this monthly member.

Answers:

Cramster Expert

Member's Avatar

(Cramster SME)
Moderator
Cramster In-House Subject Matter Expert
Date Posted: 7/23/2008 7:18:38 AM  Status: Live
Asker's Rating: Helpful   
Response:
Dear,
 
 First let you know the Red-Black Tree
 
  It is a self balancing Binary search tree allow efficient in-order traversal of elements provided that there is a way to locate the parent of any node. The search-time results from the traversal from root to leaf, and therefore a balanced tree, having the least possible tree height, results in O(log n) search time.
 
  red-black tree is a binary search tree where each node has a color attribute, the value of which is either red or black. In addition to the ordinary requirements imposed on binary search trees,
 
 Following properties will consider
  1. A node is either red or black.
  2. The root is black. (This rule is used in some definitions and not others. Since the root can always be changed from red to black but not necessarily vice-versa this rule has little effect on analysis.)
  3. All leaves are black, even when the parent is black (The leaves are the null children.)
  4. Both children of every red node are black.
  5. All paths from any given node to its leaf nodes contain the same number of black nodes.is threatened only by adding a black node, repainting a red node black, or a rotation.

Insertion:

Insertion begins by adding the node as simple binary search tree and coloring it red. What happens next depends on the color of other nearby nodes.

  • Property 3 (All leaves, including nulls, are black) always holds.
  • Property 4 (Both children of every red node are black) is threatened only by adding a red node, repainting a black node red, or a rotation.
  • Property 5 (All paths from any given node to its leaf nodes contain the same number of black nodes) is threatened only by adding a black node, repainting a red node black, or a rotation.
so, now we need to implement RB-INSERT tree for 'n' nodes.
 
    there is any empty tree shouldn't call Red-Black tree. It needs to satisfy above properties.

 Insertion begins by adding the node as simple binary search tree and coloring it red in RB-INSERT(T, z). If we needs to implement RB-INSERT-FIXUP(T, z) in these three cases atleast one node as red. So, we can easily say more than one node contains atleast one red. 
 
mugenjin's Comment:
Many thanks



By reading or posting messages on these forums, you are agreeing to the Answer Board's Terms of Service and Conduct (TSC).


About Cramster | Terms of Use | Privacy Policy | Contact Us | Press Room | Site Map | Support | Anti-Cheating Policy

Cramster.com is not affiliated with any publisher. Book covers, title and author names appear for reference only.
Copyright © 2008 Cramster, Inc.