Past-paper question · 2024 October-November · Paper 22 · Q4(a)

Question 4(a) 2024 · October-November · Paper 22 · 5 marks

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

Official answer for Question 4

Part (a)

✓
One mark per mark point

Question 5

✓
•
✓
Line 02 / DECLARE Counter : STRING
✓
should be DECLARE Counter : INTEGER
✓
•
✓
Line 09 / Temp TRUE
✓
should be Swapped TRUE
✓
•
✓
Line 10 / WHILE Swapped = TRUE OR Pass <= Limit - 1 DO
✓
should be WHILE Swapped = TRUE AND Pass <= Limit - 1 DO
✓
•
✓
Line 17 / ItemList[Counter] Temp
✓
should be ItemList[Counter + 1] Temp
✓
•
✓
Line 19 / ENDCASE
✓
should be ENDIF
✓
Correct algorithm:
✓
01
✓
DECLARE ItemList : ARRAY[1:100] OF STRING
✓
02
✓
DECLARE Counter : INTEGER
✓
03
✓
DECLARE Limit : INTEGER
✓
04
✓
DECLARE Pass : INTEGER
✓
05
✓
DECLARE Swapped : BOOLEAN
✓
06
✓
DECLARE Temp : STRING
✓
Limit 100
✓
07
✓
Pass 1
✓
08
✓
Swapped TRUE
✓
09

Question 10

✓
WHILE Swapped = TRUE AND Pass <= Limit - 1 DO
✓
Swapped FALSE

Question 11

✓
FOR Counter 1 TO Limit – Pass

Question 12

Question 13

✓
IF ItemList[Counter] > ItemList[Counter + 1]

Question 14

✓
THEN
✓
Temp ItemList[Counter]

Question 15

✓
ItemList[Counter] ItemList[Counter + 1]

Question 16

✓
ItemList[Counter + 1] Temp

Question 17

✓
Swapped TRUE

Question 18

Question 19

✓
ENDIF
✓
Pass Pass + 1

Question 20

Question 21

✓
NEXT Counter

Question 22

✓
ENDWHILE

Mark scheme 0478_w24_ms_22.pdf →

Show text version of question

Question 4

Part (a)

Question 4

This pseudocode algorithm is intended to sort a pre-populated one-dimensional (1D) array named

ItemList into alphabetical order using a bubble sort.

01 DECLARE ItemList : ARRAY[1:100] OF STRING 02 DECLARE Counter : STRING 03 DECLARE Limit : INTEGER 04 DECLARE Pass : INTEGER 05 DECLARE Swapped : BOOLEAN 06 DECLARE Temp : STRING 07 Limit 100 08 Pass 1

09 Temp TRUE 10 WHILE Swapped = TRUE OR Pass <= Limit - 1 DO 11 Swapped FALSE 12 FOR Counter 1 TO Limit – Pass 13 IF ItemList[Counter] > ItemList[Counter + 1] 14 THEN 15 Temp ItemList[Counter] 16 ItemList[Counter] ItemList[Counter + 1] 17 ItemList[Counter] Temp 18 Swapped TRUE 19 ENDCASE 20 Pass Pass + 1

21 NEXT Counter 22 ENDWHILE

Part (a)

Identify the line numbers of five errors in the pseudocode and suggest a correction for each

error.

Error 1 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 2 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 3 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Error 4 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

Question 5

, ,

Error 5 line number ...................................................................................................................

Correction .................................................................................................................................

...................................................................................................................................................

[5]
Topic relevance

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 0478_w24_qp_22.pdf

Keep practising this topic