The Binary search algorithm assumes that the items in the array are _____ and…

2023

The Binary search algorithm assumes that the items in the array are _____ and it either finds the item or eliminates half of the array with one comparison.

Answer: B. SortedConcept: Binary search locates a target in an array by repeatedly comparing it to a single middle element and discarding one whole half based on that one…

  1. A.

    Unsorted

  2. B.

    Sorted

  3. C.

    Checked

  4. D.

    Selected

Attempted by 1133 students.

Show answer & explanation

Correct answer: B

Concept: Binary search locates a target in an array by repeatedly comparing it to a single middle element and discarding one whole half based on that one comparison. This discard step is only valid when every element's position already reflects its size relative to its neighbours -- that is, the array is arranged in one consistent (ascending or descending) order.

Application -- trace on the sorted array [3, 9, 14, 21, 30, 42] (indices 0-5), target 30:

  1. Compare the target with the middle element at index 2, value 14.

  2. 30 > 14, so the entire left portion -- indices 0 to 2 (values 3, 9, 14) -- is discarded in one step: the array's order guarantees nothing there can be as large as the target.

  3. Continue in indices 3 to 5 ([21, 30, 42]); the middle element there is at index 4, value 30 -- the target is found immediately.

Only 2 comparisons were needed instead of examining all 6 elements one by one, because the order guaranteed the discarded portion could not contain the target.

Cross-check -- the same procedure breaks down without order: arrange the same six values as [21, 3, 42, 9, 14, 30] (no guaranteed relationship between neighbours), with the target 30 now sitting at index 5. Apply the identical procedure: compare the target with the middle element at index 2, value 42. Since 30 < 42, the procedure discards the entire right portion -- indices 2 to 5 (values 42, 9, 14, 30) -- exactly as it discarded the analogous portion in the sorted case. But index 5 holds the target itself, so this single comparison throws away the correct answer. The comparison's result no longer says anything reliable about where the target is, because nothing here fixes each element's position relative to its neighbours.

Why the other options don't fit:

  • Unsorted -- as the cross-check above shows, without a guaranteed relative order between neighbouring elements, one comparison against the middle can discard the very portion holding the target.

  • Checked -- 'checked' describes a state that would exist only after a comparison has already happened; it is not a property the array must have before the search starts.

  • Selected -- 'selected' implies a subset was picked out in advance; binary search must operate on the complete array as given, not on a pre-chosen part of it.

So the array must already be sorted (ordered) for the middle-element comparison to validly eliminate half the elements in a single step -- 'Sorted' is the required assumption.

Explore the full course: Up Lt Grade Assistant Teacher 2025

Loading lesson…