2210/22/M/J/22 question 4: worked solution (May/June 2022, paper 22)

Show as plain text

Cambridge O Level Computer Science 2210 · 7.7 Trace tables Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8. Q52 2210/22/M/J/22 original Q4 Structured · 9 marks Worked solution (a) Follow the flowchart one input at a time. Counter goes up by 1 after each input is dealt with. Serve goes up only when the temperature is from 63 to 86. Hot goes up when Temp is above 86. Cold goes up when Temp is below 63. Counter Hot Cold Serve Temp Error OUTPUT 0 0 0 0 1 1 75 2 2 78 3 3 84 4 1 87 Too Hot 5 2 91 Too Hot 6 4 80 7 5 75 8 6 70 9 7 65 10 1 62 Too Cold -1 30 30 At -1 the algorithm works out Error = ((2 + 1) / 10) * 100 = 30, outputs it and ends. The input 20 is never read. Counter column correct [1] Hot column correct [1] Cold column correct [1] Serve column correct [1] Temp column correct [1] Error column correct [1] OUTPUT column correct [1] (b) Add a message to explain the number that is output. Write: output a message such as "The percentage of meals not served" with the value (or output Hot, Cold and Serve as well) [1] (c) Look for a process that never changes any output. Write: the Serve ← Serve + 1 process (updating Serve) is not needed, because Serve is never used in the output or in Error [1] KEY IDEA In a trace table, update only the variable the flowchart changes on each path and write a new row for each input. TOTAL 9 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.