Which of the following statements correctly describes the color property of nodes in a red-black tree?
Recall the rule about the root node's color in red-black trees.
In red-black trees, every node is colored either red or black. The root node is always black to maintain balance properties.
What does the black-height property of a red-black tree ensure?
Think about the balance condition related to black nodes on paths from any node.
The black-height property states that every path from a given node to its descendant leaves must have the same number of black nodes, ensuring balanced black node distribution.
Given a red-black tree where a red node has a red child, which property is violated?
Recall the rule about red nodes and their children.
One key property is that red nodes cannot have red children. This prevents two reds in a row, maintaining balance.
Which statement best describes the difference in balancing between red-black trees and AVL trees?
Consider how strict each tree type is about height differences.
AVL trees maintain a stricter balance condition, which keeps the tree more balanced and improves lookup speed but can slow down insertions and deletions due to more rotations.
What is the maximum height h of a red-black tree with n internal nodes?
Choose the correct formula relating h and n.
Recall the property that the longest path is at most twice the shortest path in a red-black tree.
The maximum height of a red-black tree with n nodes is at most twice the logarithm base 2 of (n + 1). This is because red-black trees guarantee that no path is more than twice as long as any other.