How many comparisons does binary search make in the worst case to determine if a target value is present in a sorted array of 1,024 elements?

Answer and explanation

Correct answer: D. 11

  1. Step 1: Calculate the maximum search depth of binary search: .
  2. Step 2: For , the worst-case number of iterations is comparisons.
Answer
11.
Why not the others: 1,024 is the linear search worst case; 512 is the first division point; 100 is an arbitrary number.

Practise more Algorithms and Python Programming.

Free questions with an explanation for every one, and full timed EmSAT Achieve (UAE) mock tests.

How many comparisons does binary… | EmSAT Achieve (UAE)