Multiple choice binary search

For a binary search algorithm to work, it is necessary that the array (list) must be

  1. sorted

  2. unsorted

  3. in a heap

  4. popped out of stack

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The correct answer is A. sorted. For a binary search algorithm to work correctly, the array (or list) must be sorted in ascending or descending order. This allows the algorithm to efficiently divide the search space in half at each step, reducing the number of elements to be searched. If the array is unsorted, the binary search algorithm may not produce the correct results.