Computer Science · Oct / Nov 2019 · Paper 23 · Question 5
2210
As printed in the paper
The question as text
The algorithm performs an operation on the array named MyData DIV means integer division, so only the whole number part of the result is returned e.g. 7 DIV 2 returns a value of 3 First 0 Last 16 Found FALSE INPUT UserIn WHILE (First <= Last) AND (Found = FALSE) DO Middle (First + Last) DIV 2 IF MyData[Middle] = UserIn THEN Found TRUE ELSE IF UserIn < MyData[Middle] THEN Last Middle - 1 ELSE First Middle + 1 ENDIF ENDIF ENDWHILE OUTPUT Found This table shows the contents of the array: MyData e.g. MyData[2] stores the value 5 MyData Index [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] Value 2 3 5 6 8 10 12 13 14 16 18 20 25 27 29 34 36
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
5(a)[6]
5(b)[2]
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

