Skip to main content
O-LevelComputer ScienceAlgorithm design and problem-solving2210/22 · Oct/Nov 2024 · Q48 Marks

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 + 1] ← Temp 18 Swapped ← TRUE 19 ENDCASE 20 Pass ← Pass + 1 21 NEXT Counter 22 ENDWHILE

  1. (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 Error 5 line number Correction[5]
  2. (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]

Mark scheme

Marking points from the official mark scheme (Oct/Nov 2024). The mark or mark type is shown in brackets.

  1. [1] Line 02/DECLARE Counter : STRING should be DECLARE Counter : INTEGER
  2. [1] Line 09/Temp ← TRUE should be Swapped ← TRUE
  3. [1] Line 10/WHILE Swapped = TRUE OR Pass <= Limit - 1 DO should be WHILE Swapped = TRUE AND Pass <= Limit - 1 DO
  4. [1] Line 17/ItemList[Counter] ← Temp should be ItemList[Counter + 1] ← Temp
  5. [1] Line 19/ENDCASE should be ENDIF
  6. [1] The use of a flag (set initially to FALSE) to show if a swap has been made (during the current iteration)
  7. [1] to stop the loop if it has been sorted
  8. [1] The reduction in the limit of the (inner) loop after each iteration (of the loop)
  9. [1] to reduce the number of comparisons / iterations required

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Algorithm design and problem-solving, O-Level Computer Science (syllabus 2210). Structured question, 8 marks.
Source
O-Level Computer Science, Oct/Nov 2024 Paper 2 Variant 2, question 4.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep