Note AcademyNote Academy

Computer Science · Oct / Nov 2024 · Paper 22 · Question 4

2210

As printed in the paper

The question as text

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

Read automatically from the paper; the printed page above is exact.

Show the answer and mark scheme
  • 4(a)[5]

  • 4(b)[3]

Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.