Which of the following satisfies the property of the red-black tree?
2023
Which of the following satisfies the property of the red-black tree?
Answer: A. Black, if the new node is a root node — Red-black trees follow specific properties to maintain balance. One of the key properties is that the root node must always be black. This rule applies when a…
- A.
Black, if the new node is a root node
- B.
Red, if the new node is not a root node
- C.
Black, if the new node is not a root node
- D.
More than one of the above
- E.
None of the above
Attempted by 13 students.
Show answer & explanation
Correct answer: A
Red-black trees follow specific properties to maintain balance. One of the key properties is that the root node must always be black. This rule applies when a new node becomes the root during insertion. The color of other nodes (red or black) depends on insertion and rebalancing rules, not a fixed rule. Therefore, the statement that the root node is black is correct. Other options incorrectly generalize color rules for non-root nodes or claim multiple rules apply, which is not accurate. The correct property is that the root node is black.
हिन्दी उत्तर: रेड-ब्लैक ट्री में संतुलन बनाए रखने के लिए विशिष्ट गुण होते हैं। मुख्य गुणों में से एक यह है कि रूट नोड हमेशा काला होता है। यह नियम तब लागू होता है जब कोई नया नोड इन्सर्शन के दौरान रूट बनता है। अन्य नोड्स (लाल या काले) का रंग इन्सर्शन और रिबैलेंसिंग नियमों पर निर्भर करता है, न कि एक निश्चित नियम पर। इसलिए, रूट नोड काला होता है, यह कथन सही है। अन्य विकल्प गलत तरीके से गैर-रूट नोड्स के रंग के नियमों को सामान्यीकृत करते हैं या यह दावा करते हैं कि कई नियम लागू होते हैं, जो सही नहीं है। सही गुण यह है कि रूट नोड काला होता है।