Multiple choice technology mainframe

Which is more efficient search, if your number of records is more and the input is sorted

  1. Binary Search

  2. Sequential Search

  3. Both a and b

  4. None

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The correct answer is A (Binary Search). When the number of records is large and the input is already sorted, binary search is the most efficient with O(log n) time complexity. Sequential search has O(n) complexity and becomes very slow for large datasets. Binary search repeatedly divides the search interval in half, making it exponentially faster than linear search for sorted data.

AI explanation

Binary search repeatedly halves the search space by comparing the target to the middle element, giving it O(log n) time complexity, which scales far better than a sequential scan as the number of records grows. Sequential search checks each record one by one (O(n)), so it becomes increasingly inefficient on large datasets. The key requirement for binary search is that the data must already be sorted, which the question states is the case here.