Question Detail

COS 102 test topic Objective Question

Question

What is the worst-case time complexity of binary search on a sorted array containing n items?
Options
A O(log n)
Correct Answer
B O(n)
C O(n log n)
D O(1)
Correct Answer

Option A is the correct answer.

Detailed Explanation

Because the search domain is halved with every step, the worst-case number of comparisons is proportional to log2(n).

Hint

No hint available

Question Info