2210/23/O/N/22 question 4: worked solution (October/November 2022, paper 23)

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. Q54 2210/23/O/N/22 original Q4 Structured · 7 marks 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. Stock Total Sale OUTPUT 10 0 9 1 Y 8 2 Y 7 3 Y 6 4 Y 5 5 Y 4 Y Add new stock 14 6 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 IDEA Trace tables show each change as it happens; a quantity input replaces the fixed change of 1. TOTAL 7 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.