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?
- A.
O(1)
- B.
O(log n)
- C.
O(n)
- 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).