Computer Science · May / June 2026 · Paper 21 · Question 4
0478
As printed in the paper
The question as text
The following pseudocode algorithm uses a bubble sort to sort the array |£¤¥¦ Complete the algorithm. §£¨ ©{ ª« ¬ §£¨ ~¬ |£¤~®¯¦ u |£¤~®¯ x ¦ °| |£¤~®¯¦ |£¤~®¯¦ |£¤~®¯ x ¦ |£¤~®¯ x ¦ ª« |}~¬ |± ~®¯ §£¨ §£¨ |~§ ª« §£¨ w [4]
Read automatically from the paper; the printed page above is exact.
Show the answer and mark scheme
One mark for each correct completion
Last ← __50____
REPEAT
Swap ← __FALSE___
FOR __Index___ ← 1 TO Last - 1
IF Names[Index] > Names[Index + 1]
THEN
Temp ← Names[Index]
Names[Index] ← Names[Index + 1]
Names[Index + 1] ← Temp
Swap ← TRUE
ENDIF
NEXT Index
Last ← Last - 1
UNTIL __NOT // False =__ Swap OR Last = 1
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

