Question 5(b) 2019 · October-November · Paper 23 · 100 marks
Reveal official mark-scheme answer
Official answer for Question 5
Part (b)
Question 2
- Search for the value input «
- « using an array«
- « of sorted data
Show text version of question
Question 5
Part (b)
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 (b)
Describe the function being performed by the algorithm.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
.............................................................................................................................................
Question 11
Why this question appears here
99% assigned-topic match · Programming › Programming concepts
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
