Question:

When does the worst case of binary search occur?

Show Hint

Binary search performs well in sorted arrays but reaches its worst case when it must check every possible division down to a single element.
Updated On: Feb 15, 2025
  • When the element is present at the middle of the array
  • When the element is present at the first position
  • When the element is not in the array or is found at the last level of recursion
  • When the element is at the second position
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Binary search operates by repeatedly dividing the search space in half at each step. The worst-case scenario occurs when the search must continue until the smallest possible subarray is reached.
- If the target element is absent from the array, the search will proceed until all elements have been checked.
- Likewise, if the element is located only at the final level of recursion, it means the maximum number of comparisons was required.
- The worst-case time complexity is \( O(\log n) \), which happens when the array is continuously halved until a single element remains.
Conclusion: The worst case for binary search arises when the element is either missing from the array or is found only at the deepest level of recursion.
Was this answer helpful?
0
0