Q. In a Red-Black tree, what property ensures that the tree remains balanced?
A.
Every node has two children
B.
The root is always black
C.
No two red nodes can be adjacent
D.
All leaves are at the same level
Solution
In a Red-Black tree, no two red nodes can be adjacent, which helps maintain balance and ensures that the longest path from the root to a leaf is no more than twice as long as the shortest path.
Correct Answer:
C
— No two red nodes can be adjacent
Q. What is a key difference between AVL trees and Red-Black trees?
A.
AVL trees are faster for search operations
B.
Red-Black trees are always balanced
C.
AVL trees allow duplicate values
D.
Red-Black trees are more complex to implement
Solution
AVL trees are generally faster for search operations due to their stricter balancing criteria, while Red-Black trees allow for faster insertion and deletion operations.
Correct Answer:
A
— AVL trees are faster for search operations