Binary search is one of the most widely used search algorithms and gives the best performance in worst-case scenarios. As discussed in the previous section, linear search can perform at O(n) in the worst case, whereas binary search uses divide-and-conquer techniques to perform the search as fast as O(log n).
Though binary search is faster in performance, it can only be applied if the collection is already sorted. If the collection is not sorted, then linear search is the only way to perform the search.