The time complexity of binary search is:
-
A
O(n)
-
B
O(log n)
Correct answer
-
C
O(n²)
-
D
O(1)
Correct answer
B. O(log n)
10 views
Explanation
Binary search halves the search space each time, so it runs in O(log n) time. Linear search is O(n).
Reference
Asked in: Matric,FBISE
Doubts & discussion
Not sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ