2210/22/M/J/25 question 5: worked solution (May/June 2025, paper 22)
Show as plain textHide plain text
Cambridge O Level Computer Science 2210 · 7.8 Identifying and correcting errors in algorithms Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 7 of 8. Q78 2210/22/M/J/25 original Q5 Structured · 11 marks Worked solution (a) Compare each line with what the algorithm should do. Write any five of these: Line 01: Names holds text, so ARRAY[1:500] OF STRING [1] Line 09: Total must start at zero, so Total ← 0 [1] Line 11: the index must change each time, so INPUT Names[Counter] [1] Line 13: the height must be added to the total, so Total ← Total + Heights[Counter] [1] Line 20: the output must be the shortest height, so OUTPUT "The shortest height is ", Shortest (or Heights[Index]) [1] (b) Use the ROUND function with 1 decimal place around the calculation: OUTPUT ROUND(Total / 500, 1) OUTPUT with the correct average calculation (Total / 500, or an Average variable) [1] ROUND used with 1 as the number of decimal places [1] (c) Add a second check beside the shortest check, as follows: Declare a new variable such as Tallest at the start [1] Set Tallest to a low number such as 0 before the loop [1] Inside the loop, after the height is input, add an IF to compare Heights[Counter] with Tallest [1] If the height is larger, set Tallest to Heights[Counter] [1] After the loop ends, OUTPUT Tallest. This also scores, but the maximum for this part is 4. KEY IDEA Totals must start at 0, use the loop counter as the index and be output only after the loop. TOTAL 11 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by Mr Bulmer's Learning Zone. Tap the picture to open it on YouTube.