9618/23/M/J/24 question 7: worked solution (May/June 2024, paper 23)

Show as plain text

Cambridge AS Level Computer Science 9618 · 12.2 Program Design Worked solution from the Software Development Paper 2 Problem-solving and Programming booklet, Part 2 of 3. Q25 9618/23/M/J/24 original Q7 Structured · 9 marks Worked solution (a)(i) A function returns a value. Mod-B returns a Boolean and Mod-E returns an integer. Write: Mod-B and Mod-E [1] (a)(ii) Say what happens to Par3 in each module after the call ends: By reference (Mod-G): any change made to Par3 inside Mod-G is kept, so the changed value is seen in the calling module Mod-C afterwards [1] By value (Mod-F): a copy is used, so any change made to Par3 inside Mod-F is not seen in Mod-C afterwards [1] (b) Draw the chart with Mod-A at the top, Mod-B and Mod-C below it, and Mod-D, Mod-E, Mod-F, Mod-G on the bottom row. Draw it like this: Boxes: Mod-A at the top. Mod-B and Mod-C under it. Mod-D and Mod-E under Mod-B. Mod-F and Mod-G under Mod-C. Join them with lines. [1] Mod-A to Mod-B: arrows for Par1 and Par2 going down, and a Boolean return value going up [1] Mod-A to Mod-C: Par1 going down, and Par3 going down and up (two-way, because it is by reference) [1] Draw a decision diamond under Mod-B only, because it calls either Mod-D or Mod-E [1] Draw an iteration (curved) arrow across the lines under Mod-C only, because it repeats Mod-F then Mod-G [1] Lower level: Par2 down to Mod-D; Par3 down to Mod-E with an integer return value up; Par3 down to Mod-F; Par3 two-way to Mod-G [1] KEY IDEA A structure chart shows which module calls which, with arrows for data going down, return values going up, a diamond for choice and a curved arrow for repetition. TOTAL 9 marks Official mark scheme VIDEO ▶ Starts at Q7 (1:00:17) Starts at Q7 (1:00:17) · by Pseudocode Pro. Tap the picture to open it on YouTube.