+1 vote
in Data Structures & Algorithms I by (110k points)
What is the special property of red-black trees and what root should always be?

(a) a color which is either red or black and root should always be black color only

(b) height of the tree

(c) pointer to next node

(d) a color which is either green or black

I'm obligated to ask this question of Red Black Tree in chapter Binary Trees of Data Structures & Algorithms I

The question was asked in a job interview.

1 Answer

+1 vote
by (672k points)
selected by
 
Best answer
Right option is (a) a color which is either red or black and root should always be black color only

The best explanation: An extra attribute which is a color red or black is used. root is black because if it is red then one of red-black tree property which states that number of black nodes from root to null nodes must be same, will be violated.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...