Alorithms · Class 12 · CBSE · Science Computer Science

Which condition is necessary before applying binary search to an array?

Practice question from Alorithms (Class 12 · CBSE · Science Computer Science), with the correct answer and a step-by-step solution.

easy · MCQ · Q-203DC4

Which condition is necessary before applying binary search to an array?

  1. A.The array must contain only integer values.
  2. B.The array must be sorted.Correct answer
  3. C.The array must have an even number of elements.
  4. D.The array must not contain duplicate values.

Solution

Binary search repeatedly compares the target with the middle element and eliminates half of the search space. This elimination is valid only when the elements are arranged in sorted order.

More from Alorithms

All of Alorithms

Practise more Computer Science

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed