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

Question 4(b) 2024 · October-November · Paper 22 · 3 marks

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

Official answer for Question 4

Part (b)

✓
One mark per mark point (max three)

Question 3

✓
•
✓
The use of a flag (set initially to FALSE) to show if a swap has been
✓
made (during the current iteration)
✓
•
✓
… to stop the loop if it has been sorted
✓
•
✓
The reduction in the limit of the (inner) loop after each iteration (of the loop)
✓
•
✓
… to reduce the number of comparisons / iterations required
✓
Cambridge IGCSE – Mark Scheme
✓
0478/22
✓
October/November
✓
PUBLISHED
✓
2024
✓
Question
✓
Answer
✓
Marks

Mark scheme 0478_w24_ms_22.pdf →

Show text version of question

Question 4

Part (b)

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 (b)

A bubble sort algorithm can be written to include features that make it more efficient.

Explain why the corrected bubble sort algorithm is efficient.

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

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

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

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

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

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

[3]
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