Question PSC-ARR-0007
EasyWhat will be the output of the following pseudocode?
Integer a[] = {1, 2, 3, 4, 5}
Integer i = 0
while (i < 5 AND a[i] != 4)
i = i + 1
end while
Print i
- A.
4
- B.
2
- C.
Show answer and explanation
Answer: D
This is linear search: 4 is at index 3.