What is the primary advantage of using binary search over linear search?
-
Binary search is easier to implement.
-
Binary search works on unsorted arrays.
-
Binary search has a time complexity of O(log n).
-
Binary search can find all occurrences of an element.