Past-paper question · 2019 May-June · Paper 42 · Q4(a)(i)

Question 4(a)(i) 2019 · May-June · Paper 42 · 4 marks

Original past-paper question for 4(A)(I)
Original past-paper question for 4(A)(I)
Reveal official mark-scheme answer Official mark-scheme answer for 4(A)(I)

Official answer for Question 4

Part (a)

(i)

Question 1

mark for error and correction

Question 4

✓
Error 1 – IF List[LowerBound] = SearchValue
✓
Correction – IF List[MidPoint] = SearchValue
✓
Error 2 – UpperBound ← MidPoint + 1
✓
Correction – LowerBound ← MidPoint + 1
✓
Error 3 – IF LowerBound > MidPoint
✓
Correction - IF LowerBound > UpperBound
✓
Error 4 – IF ValueFound = FALSE
✓
Correction – IF ValueFound = TRUE

Mark scheme 9608_s19_ms_42.pdf →

Show text version of question

Question 4

Part (a)

(i)

A
program has sorted some data in the array, List, in ascending order.

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 ..........................................................................................................................

[4]
Topic relevance

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

Keep practising this topic