JAMIA 2026 — Computer PYQ
JAMIA | Computer | 2026What is the best-case time complexity of the binary search algorithm?
Choose the correct answer:
- A.
O(1)
(Correct Answer) - B.
O(n)
- C.
O(log n)
- D.
O(nlog n)
O(1)
Explanation
Correct Option: (a) O(1)
Solution
How Binary Search Works
Binary Search is an efficient divide-and-conquer algorithm used to find the position of a target value within a sorted array.
The algorithm continuously calculates the middle index of the current search space using the formula:
mid=low+⌊2high−low⌋
It then compares the target element with the element present at the array index mid (A[mid]).
Breakdown of Asymptotic Cases
Best-Case Scenario O(1): The best-case occurs when the target element is located exactly at the first middle position calculated by the algorithm. Because the match is found on the very first comparison, the execution completes instantly in constant time, regardless of the size of the array (n).
Best-Case Time Complexity=O(1)
Worst-Case Scenario O(logn): The worst-case occurs when the target element is either at the extreme ends of the array or not present at all. In each step, the search space is cut exactly in half. The maximum number of comparisons required can be modeled by solving the recurrence relation T(n)=T(n/2)+c, which yields:
Worst-Case Time Complexity=O(log2n)
Average-Case Scenario O(logn): Statistically, considering all possible target positions, the average number of splits needed to locate the target still grows logarithmically with respect to n.
Complexity Analysis Summary Table
Operational Case | Asymptotic Complexity | Scenario Condition |
Best-Case | O(1) | Target element is exactly at the middle index on the first check. |
Average-Case | O(logn) | Target element is found after a few splits down the decision tree. |
Worst-Case | O(logn) | Target element is at the final leaf level or absent from the array. |
Hence, while many students mistakenly select option (c) by confusing it with the general/worst-case performance, the best-case time complexity is strictly constant time, which is represented by (a) O(1).
