✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Recall binary search:
lo ← 0
hi ← n-1
WHILE lo < hi
mid ← (lo+hi) DIV 2
IF a[mid] = k
RETURN mid
IF a[mid] < k
lo ← mid+1
IF a[mid] > k
hi ← mid-1
RETURN -1;
where DIV is division discarding any remainder to return a whole number.
Given the following array:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| B | C | F | G | J | K | M | N | P | Q | S | T | U | W | Y |
How many values in the array will be examined in a binary search for the key K?