Worked question 3 - 1D and 2D Array Processing: Writing and Tracing Programs
rainfall = [[2, 0, 5, 8, 1], [0, 0, 3, 4, 2], [6, 4, 7, 5, 3]]
Describe, using structured English or pseudocode, an algorithm to find which town (index 0, 1 or 2) had the highest total rainfall across the 5 days, and state the total for that town.
Answer and mark scheme
Question 3
| Credit | Answer or working |
|---|---|
| 1-2 | Level 1 A basic or partial idea is given (e.g. only calculating one town's total, or only stating an answer with no method), with little use of correct pseudocode/structured English. |
| 3-4 | Level 2 An algorithm is described that calculates the total rainfall for each town, using loops correctly for at least the row-total part, but the method for finding which town has the highest total is incomplete, unclear, or missing. |
| 5-6 | Level 3 A complete, correctly ordered algorithm is described (in pseudocode or clear structured English) that calculates each town's total rainfall using a loop, then correctly identifies the town with the highest total (e.g. by comparing totals as they are calculated, similar to a find-the-maximum pattern), and the correct town and total (town 2, 25mm) are stated. |
- Indicative content:
- For each town (row), loop through its 5 days and add up the rainfall values to get that town's total
- Keep track of the highest total seen so far, and which town it belongs to, updating them whenever a new town's total is higher
- This is similar to the standard find-the-maximum pattern, but applied to a total calculated for each row rather than to single stored values
- After checking all 3 towns, output the town with the highest total and its rainfall total
- Working: town 0 total = 2+0+5+8+1 = 16; town 1 total = 0+0+3+4+2 = 9; town 2 total = 6+4+7+5+3 = 25
- Town 2 has the highest total rainfall, with 25mm
Answer: Calculate each town's total rainfall in turn (town 0 = 16mm, town 1 = 9mm, town 2 = 25mm) and keep track of the highest total seen; town 2 has the highest total, with 25mm.

