Cambridge O Level Computer Science 2210 · 7.7 Trace tables

Q54 · 2210/23/O/N/22 Q4

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

Q542210/23/O/N/22original Q4Structured · 7 marks
Question 4 from 2210/23/O/N/22

Worked solution

(a)

Follow the flowchart. Each Y takes 1 off Stock and adds 1 to Total. When Stock goes below 5, it outputs a message and adds 10. The N ends the algorithm and outputs Total.

StockTotalSaleOUTPUT
100
91Y
82Y
73Y
64Y
55Y
4YAdd new stock
146
N
6

Stock column correct [1]

Total column correct [1]

Sale column correct [1]

OUTPUT column correct [1]

(b)

Add an input for how many wheelbarrows are sold. Any three of these:

Input a number (quantity) sold [1]

Check that the number is less than or equal to the Stock, after checking that Sale is not "N" [1]

Update Stock by that number: Stock ← Stock - Number [1]

Update Total by that number: Total ← Total + Number (also credited, but only three marks are available).

KEY IDEATrace tables show each change as it happens; a quantity input replaces the fixed change of 1.
TOTAL 7 marks

Official mark scheme

Mark scheme for 2210/23/O/N/22 question 4
VIDEO
▶ Topic lesson

A lesson on this topic · by Mr Bulmer's Learning Zone. 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.