Science & Tech· Data structures
What is the time to perform search, insert and delete operations in the average case as well as the worst case by using an AVL tree?
- aO(n)
- bO(log n)
- cO(n²)
- dO(n log n)
Show answer and explanation
Answer: (b) O(log n)
An AVL tree is a self-balancing binary search tree: after every insertion or deletion, rotations keep the heights of each node's two subtrees within one of each other. Its height therefore stays proportional to log n, so search, insert and delete all take O(log n) time in both the average and the worst case. An unbalanced binary search tree can fall to O(n) in the worst case, which is what the AVL tree avoids.
Source: UPSC Engineering Services (P) 2025 · Q84