Multiple choice

One of the conditions used to control the DO WHILE...LOOP in a binary search is that

  1. the target value should match the middle value

  2. the last element of the array should have been reached

  3. the size of the gap should be zero

  4. the size of the gap should be greater than zero

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

In a binary search algorithm implemented with a loop, the search continues as long as the search space or gap between the low and high pointers is greater than zero, meaning there are still elements to examine.