Exam-style question
Try this first
A search algorithm halves the remaining search area after each comparison. Which time complexity best describes the algorithm in the general case?.
- A.O(1)
- B.O(log n)
- C.O(n)
- D.O(n^2)
Model answer
What a good answer should say
- O(log n)
Explanation
Why this works
If the remaining problem is repeatedly divided by two, the number of steps grows logarithmically with n.
Common mistake
No common mistake is linked to this question yet.
