Algorithms and Data Structures · Middle · Question 39 of 75
What problem do self-balancing trees (AVL, red-black) solve?
- ✓Correct answer: They keep the height O(log n), so operations stay fast
- 2They store duplicate keys in a more compact way
- 3They let every node have more than two children
Explanation
After inserts and deletes they rotate nodes to keep the tree roughly balanced. Ordered maps in many languages (Java TreeMap, C++ std::map) are red-black trees.