What is the time complexity of searching for an element in a binary search…

2025

What is the time complexity of searching for an element in a binary search tree, assuming that the tree is balanced?

  1. A.

    O(1)

  2. B.

    O(log n)

  3. C.

    O(n)

  4. D.

    O(n log n)

Attempted by 275 students.

Show answer & explanation

Correct answer: B

The time complexity of searching for an element in a balanced binary search tree is O(log n). However, it’s important to note that in the worst-case scenario (if the tree is skewed), the time complexity could become O(n).

Explore the full course: Cocubes Preparation