Searching · Class 12 · CBSE · Science Computer Science

In binary search on an ascending sorted list, what should be done when a[mid] is less than the target value x?

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

medium · MCQ · Q-AE88AC

In binary search on an ascending sorted list, what should be done when a[mid] is less than the target value x?

  1. A.Set high = mid - 1
  2. B.Set low = mid + 1Correct answer
  3. C.Set low = mid - 1
  4. D.Stop the search because x is absent

Solution

Since the list is in ascending order, all elements at or before mid are less than x. The search must continue in the right portion by setting low = mid + 1.

More from Searching

All of Searching

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