Cosider the below formations of red-black tree. All the above formations are incorrect for it to be a redblack tree. then what may be

Cosider the below formations of red-black tree.
All the above formations are incorrect for it to be a redblack tree. then what may be the correct order?
A. 50-black root, 18-red left subtree, 100-red right subtree
B. 50-red root, 18-red left subtree, 100-red right subtree
C. 50-black root, 18-black left subtree, 100-red right subtree
D. 50-black root, 18-red left subtree, 100-black right subtree
 
Answer: A
Explanation: Considering all the properties of red-black tree, 50 must be the black root and there are two possibilities for subtrees. one is option “50-black root, 18-red left subtree, 100-red right subtree” and other is making all nodes of the tree to be black.
 

Tìm kiếm

Back
Top