Question 5(a) 2019 · October-November · Paper 23 · 100 marks
Reveal official mark-scheme answer
Official answer for Question 5
Part (a)
Question 6
Question 16
Question 16
Question 10
Question 8
Question 7
Question 10
Question 3
Question 4
Question 7
Question 10
Question 5
Show text version of question
Question 5
Part (a)
Question 5
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]
Value 2 3 5 6 8 10 12 13 14 16 18 20 25 27 29 34 36
Part (a)
Complete the trace table for the input data: 10
First Last UserIn Middle Found OUTPUT
Why this question appears here
98% assigned-topic match · Algorithm design and problem-solving
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 2210_w19_qp_23.pdf
