What is the maximum number of comparisons binary search needs to find a key in a sorted array of 1000 elements?
Correct answer D. 10
Explanation
Each comparison halves the remaining range, so the worst case is floor(log₂ n) + 1 comparisons. Since 2^9 = 512 and 2^10 = 1024, floor(log₂ 1000) is 9, giving 10. Linear search could need all 1000 comparisons, which shows why binary search's O(log n) cost matters for large sorted data.
Answer checked How we write and check questions
Discussion