What is the worst-case time complexity of searching for an element in a balanced binary search tree (AVL tree) containing n nodes?

Answer and explanation

Correct answer: A. O(log n)

  1. Step 1: In a self-balancing binary search tree (such as an AVL or Red-Black tree), the tree height is strictly maintained at .
  2. Step 2: Each comparison eliminates half of the remaining subtrees, ensuring that search, insertion, and deletion operate in worst-case logarithmic time .
Answer
O(log n).
Why not the others: is average hash map lookup; is worst-case for degenerate unbalanced BSTs or linear search; is optimal comparison sorting.

Practise more Algorithms and Python Programming.

Free questions with an explanation for every one, and full timed EmSAT Achieve (UAE) mock tests.