1.

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 blackI'm obligated to ask this question of Red Black Tree in chapter Binary Trees of Data Structures & Algorithms IThe question was asked in a job interview.

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.



Discussion

No Comment Found

Related InterviewSolutions