9618/22/O/N/22 question 5: worked solution (October/November 2022, paper 22)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 11.2 Constructs Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 2 of 3. Q42 9618/22/O/N/22 original Q5 Structured · 4 marks Worked solution Work out when each CALL runs. Sub1 runs when A, B and C are all TRUE. Sub2 runs when A and B are TRUE and C is FALSE. Sub3 runs when A is FALSE and C is FALSE (B can be either, because both paths call Sub3). Sub4 runs when A is FALSE and C is TRUE. Write: IF A AND B AND C THEN CALL Sub1() ENDIF IF A AND B AND NOT C THEN CALL Sub2() ENDIF IF NOT A AND NOT C THEN CALL Sub3() ENDIF IF NOT A AND C THEN CALL Sub4() ENDIF First IF...THEN...ENDIF correct: A AND B AND C calls Sub1() [1] Second correct: (A AND B) AND NOT C calls Sub2() [1] Third correct: (NOT A) AND (NOT C) calls Sub3(), with B left out because it does not matter [1] Fourth correct: (NOT A) AND C calls Sub4(), with B left out [1] KEY IDEA Trace each CALL back to the conditions that reach it, then drop any variable that does not change the outcome. TOTAL 4 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Audere Prep. Tap the picture to open it on YouTube.