Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 7 of 8.
Find the five mistakes and write each fix.
Line 02: STRING should be INTEGER (Counter is a loop counter) [1]
Line 09: Temp ← TRUE should be Swapped ← TRUE [1]
Line 10: OR should be AND [1]
Line 17: ItemList[Counter] ← Temp should be ItemList[Counter + 1] ← Temp [1]
Line 19: ENDCASE should be ENDIF [1]
Write any three of these points:
A flag (Swapped, set to FALSE at the start of each pass) shows if a swap was made [1]
The flag stops the loop when a pass makes no swap, because the data is sorted [1]
The limit of the inner loop is reduced after each pass (Limit - Pass), so fewer comparisons and repeats are needed [1]
▶ Topic lesson
A lesson on this topic · by Mr Bulmer's Learning Zone. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.