Q. What is the main advantage of using balanced trees like AVL and Red-Black Trees?
A.
They use less memory
B.
They guarantee O(log n) time complexity for all operations
C.
They are easier to implement
D.
They can store duplicate values
Solution
The main advantage of using balanced trees like AVL and Red-Black Trees is that they guarantee O(log n) time complexity for search, insertion, and deletion operations, ensuring efficient performance.
Correct Answer:
B
— They guarantee O(log n) time complexity for all operations
Q. Which of the following is true about the performance of AVL trees?
A.
Faster than Red-Black Trees for all operations
B.
Slower than Red-Black Trees for all operations
C.
Faster for search operations but slower for insertions
D.
Slower for search operations but faster for insertions
Solution
AVL trees provide faster search operations due to their stricter balancing, but they can be slower for insertions and deletions because they may require more rotations.
Correct Answer:
C
— Faster for search operations but slower for insertions