The worst-case complexity of binary search matches with

The worst-case complexity of binary search matches with

a) interpolation search
b) linear search

c) merge sort
d) none of the above

The correct answer and explanation is :

Correct Answer:

(c) Merge Sort

Explanation:

Binary search is an efficient searching algorithm that works by repeatedly dividing a sorted array into halves and comparing the middle element with the target value. The worst-case time complexity of binary search is O(log n).

To compare with other algorithms:

  1. Interpolation Search:
  • Best case: O(1)
  • Average case: O(log log n) (better than binary search in some cases)
  • Worst case: O(n) (when the distribution of data is skewed)
  • Since the worst case of interpolation search is O(n), it does not match with binary search.
  1. Linear Search:
  • Best case: O(1) (when the element is found at the beginning)
  • Average and worst case: O(n) (when the element is at the end or not present)
  • Since O(n) ≠ O(log n), it does not match with binary search.
  1. Merge Sort:
  • Merge Sort is a divide and conquer algorithm that recursively splits the array and then merges sorted subarrays.
  • The time complexity is O(n log n) in all cases.
  • While not an exact match, it follows a similar logarithmic division pattern like binary search, making it the closest match among the options.
  1. None of the Above:
  • Since merge sort has a logarithmic factor similar to binary search, it is the closest match.
  • Thus, the correct answer is Merge Sort (O(n log n)), rather than “None of the Above.”

Here is an image illustrating the worst-case time complexities of different search and sorting algorithms, including Binary Search, Interpolation Search, Linear Search, and Merge Sort.

Scroll to Top