Question 76Asked in DSSSB PGT Computer Science (Technical), 11 Jul 2021

Consider a sorted array of 10,00,000 elements. What is the maximum number of comparison required to find the location an item using binary search?

  1. A20
  2. B6
  3. C31
  4. D7
Show answerHide answer

Correct answer: (A) 20

Explanation

Binary search needs at most ⌈log₂(n+1)⌉ comparisons. 2²⁰ = 1,048,576 ≥ 10,00,000, so the maximum is 20.

From DSSSB PGT Computer Science PYQ (Technical), 11 Jul 2021

This is question 76 of DSSSB PGT Computer Science PYQ (Technical), 11 Jul 2021. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.