Question PSC-ARR-0069
HardWhat will be the output of the following pseudocode?
Integer a[7] = {1, 3, 5, 7, 9, 11, 13}
Integer lo = 0, hi = 6, target = 8, mid
while (lo <= hi)
mid = (lo + hi) / 2
if (a[mid] < target)
lo = mid + 1
else
hi = mid - 1
end if
end while
Print lo
- A.
3
- B.
5
- C.
-1
- D.
4
Sign up free to see the answer and a step-by-step explanation.