Computer Science EngineeringHardISRO SC (CS)

The worst-case number of key comparisons binary search makes on a sorted array of 7 elements (counting one three-way comparison per probe) is:

  1. A. 2
  2. B. 4
  3. C. 5
  4. D. 3

Correct answer: D. 3

Worst case = floor(log2 n) + 1 = 3.

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic