9618/33/O/N/24 question 10: worked solution (October/November 2024, paper 33)
Show as plain textHide plain text
Cambridge A2 Level Computer Science 9618 · 16.2 Translation Software Worked solution from the System Software Paper 3 Advanced Theory booklet, Part 2 of 2. Q31 9618/33/O/N/24 original Q10 Structured · 9 marks Worked solution (a) Each syntax diagram becomes one BNF rule. A choice becomes | and a box that can be skipped becomes two alternatives. <operator> ::= + | – | * | / [1] <label> ::= <letter><digit> | <letter><digit><digit> [1] For <equation>, write the first part: <equation> ::= <label> = [1] Then add the second part: <label><operator><label> [1] (b)(i) Draw one line from the start. It splits into two routes: a letter box or a symbol box. Both routes join again before a digit box. After the digit, put a symbol box, then a second symbol box that can be skipped by a bypass line, before the end arrow. Start goes to either letter or symbol [1] Ends with one symbol or two symbols (second symbol can be bypassed) [1] Digit box, and all other connections and the label password correct [1] (b)(ii) Write out every possible first character, then the digit, then one or two symbols. <password> ::= <letter><digit><symbol> | <letter><digit><symbol><symbol> | <symbol><digit><symbol> | <symbol><digit><symbol><symbol> First option, <letter><digit><symbol>, correct [1] The other three options correct [1] Another correct way uses helper rules: <first> ::= <letter>|<symbol>, <last> ::= <symbol>|<symbol><symbol> and <password> ::= <first><digit><last>. Any two correct lines score [1] , all three [2] . KEY IDEA A syntax diagram and BNF show the same rule: a choice is |, and an optional or repeated part needs its own alternatives or a recursive rule. TOTAL 9 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.