Question 4(a)(i) 2019 · May-June · Paper 42 · 4 marks
Reveal official mark-scheme answer
Official answer for Question 4
Part (a)
(i)
Question 1
mark for error and correction
Question 4
Show text version of question
Question 4
Part (a)
(i)
The following binary search algorithm is used to search for a value in the array.
01 ValueFound FALSE 02 UpperBound LengthOfList - 1 03 LowerBound 0 04 NotInList FALSE 05 06 WHILE ValueFound = FALSE AND NotInList = FALSE 07 MidPoint ROUND((LowerBound + UpperBound) / 2) 08 09 IF List[LowerBound] = SearchValue 10 THEN 11 ValueFound TRUE 12 ELSE 13 IF List[MidPoint] < SearchValue 14 THEN 15 UpperBound MidPoint + 1 16 ELSE 17 UpperBound MidPoint – 1 18 ENDIF 19 IF LowerBound > MidPoint 20 THEN 21 NotInList TRUE 22 ENDIF 23 ENDIF 24 ENDWHILE
Question 25
26 IF ValueFound = FALSE 27 THEN 28 OUTPUT "The value is in the list" 29 ELSE 30 OUTPUT "The value is not found in the list" 31 ENDIF
Note: The pseudocode function ROUND(Reall : REAL) RETURNS INTEGER rounds a number to the nearest integer value. For example: ROUND(4.5) returns 5 and ROUND(4.4) returns 4
Question 17
(i)
There are four errors in the algorithm.
Write the line of code where an error is present and write the correction in pseudocode.
Error 1 ...............................................................................................................................
Correction ..........................................................................................................................
Error 2 ...............................................................................................................................
Correction ..........................................................................................................................
Error 3 ...............................................................................................................................
Correction ..........................................................................................................................
Error 4 ...............................................................................................................................
Correction ..........................................................................................................................
Why this question appears here
71% assigned-topic match · Algorithm design and problem-solving › Algorithms
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 9608_s19_qp_42.pdf
