Question 1
1 markThis pseudocode searches the array Names[1:25].
Index ← 0
Found ← FALSE
REPEAT
Index ← Index + 1
IF Names[Index] = SearchName
THEN
Found ← TRUE
ENDIF
UNTIL Found OR Index = 25SearchName is not stored in the array. State the value of Index when the loop ends.
Model answer
25
Explanation
Index is increased at the start of each pass, before the comparison, so on the last pass it becomes 25, Names[25] is checked, and then the condition Index = 25 ends the loop. It never reaches 26, unlike searches that increase the index after the comparison.
Mark scheme
-
1 mark
25
Do not accept 26