Cambridge O Level Computer Science 2210 · 7.7 Trace tables

Q52 · 2210/22/M/J/22 Q4

Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8.

Q522210/22/M/J/22original Q4Structured · 9 marks
Question 4 from 2210/22/M/J/22

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.

CounterHotColdServeTempErrorOUTPUT
0000
1175
2278
3384
4187Too Hot
5291Too Hot
6480
7575
8670
9765
10162Too Cold
-13030

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 IDEAIn 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

Mark scheme for 2210/22/M/J/22 question 4
VIDEO
▶ Whole paper

Video solution of the whole paper · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.