2210/23/O/N/20 question 4: worked solution (October/November 2020, 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. Q48 2210/23/O/N/20 original Q4 Structured · 6 marks Worked solution (a) Run the flowchart for each pair of inputs. MOD gives the remainder. If Y is greater than Z use A ← Y MOD Z, otherwise A ← Z MOD Y. A = 0 gives Valid, anything else gives Invalid. The algorithm ends when Y = 0. Y Z A OUTPUT 11 4 3 Invalid 6 2 0 Valid 3 9 0 Valid 3 2 1 Invalid 2 6 0 Valid 0 0 Y column correct [1] Z column correct [1] A column correct [1] OUTPUT column correct [1] (b) Write two of these: It checks if the remainder is zero when the larger number is divided by the smaller number [1] It checks if the larger number is a multiple of the smaller number (or the smaller number is a factor of the larger) [1] Any two of these points score. KEY IDEA Trace one row at a time: MOD gives the remainder, and a remainder of 0 means one number divides exactly into the other. TOTAL 6 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.