Q. What is the primary advantage of using binary search over linear search?
A.
Binary search is easier to implement.
B.
Binary search works on unsorted arrays.
C.
Binary search has a time complexity of O(log n).
D.
Binary search can find all occurrences of an element.
Solution
Binary search has a time complexity of O(log n), making it significantly faster than linear search, which has a time complexity of O(n), especially for large datasets.
Correct Answer:
C
— Binary search has a time complexity of O(log n).