Past-paper question · 2021 May-June · Paper 23 · Q5

Question 5 2021 · May-June · Paper 23 · 8 marks

Original past-paper question for 5
Original past-paper question for 5
Original past-paper question for 5
Reveal official mark-scheme answer Official mark-scheme answer for 5

Official answer for Question 5

Question 8

✓
PROCEDURE
✓
Sort()
✓
DECLARE
✓
Temp : INTEGER
✓
DECLARE
✓
NoSwaps : BOOLEAN
✓
DECLARE
✓
Boundary, Row, Col : INTEGER
✓
Boundary ← 999
✓
REPEAT
✓
NoSwaps ← TRUE
✓
FOR Row ← 1 TO Boundary
✓
IF Result[Row, 2] > Result[Row + 1, 2] THEN
✓
FOR Col ← 1 TO 2
✓
Temp ← Result [Row, Col]
✓
Result [Row, Col] ← Result [Row + 1, Col]
✓
Result [Row + 1, Col] ← Temp
✓
NEXT Col
✓
NoSwaps ← FALSE
✓
ENDIF
✓
NEXT J
✓
Boundary ← Boundary - 1
✓
UNTIL NoSwaps = TRUE
✓
ENDPROCEDURE
✓
Mark as follows:

Question 1

✓
Outer loop

Question 2

✓
Inner loop

Question 3

✓
Correct comparison in a loop

Question 4

✓
Correct swap of col1 array elements in a loop

Question 5

✓
Correct swap of col2 array elements in a loop (via loop or separate
✓
statements)

Question 6

✓
'NoSwap' mechanism: Conditional outer loop including flag reset

Question 7

✓
'NoSwap' mechanism: Set flag in inner loop to indicate swap

Question 8

✓
Reducing Boundary in the outer loop
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_s21_ms_23.pdf →

Show text version of question

Question 5

A
global 2D array Result of type INTEGER is used to store a list of exam candidate numbers

together with their marks. The array contains 2000 elements, organised as 1000 rows and 2 columns.

Column 1 contains the candidate number and column 2 contains the mark for the corresponding candidate. All elements contain valid exam result data.

A
procedure Sort() is needed to sort Result into ascending order of mark using an efficient

bubble sort algorithm.

Write pseudocode for the procedure Sort().

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Question 15

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

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

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

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

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

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

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

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

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

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

[8]

Question 16

Topic relevance

Why this question appears here

92% 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 9618_s21_qp_23.pdf

Keep practising this topic