← Quiz: Binary Search Tree Operations: all 15 questions
Quiz: Binary Search Tree Operations · Question 10 of 15
Why are Java's TreeMap operations guaranteed O(log n) while a plain BST is not?
Why are Java's TreeMap operations guaranteed O(log n) while a plain BST is not?
- A.TreeMap uses hashing internally
- B.TreeMap stores keys in a sorted array
- C.TreeMap is a red-black tree, which rebalances itself to keep the height about log n
- D.TreeMap forbids sorted input
Answer & explanation
Correct answer: TreeMap is a red-black tree, which rebalances itself to keep the height about log n
Self-balancing trees perform rotations on insert and delete so that the height never grows like a chain.
Can you get the rest right without peeking?
Take the timed Quiz: Binary Search Tree Operations quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →