9618/31/O/N/24 question 10: worked solution (October/November 2024, paper 31)
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. Q29 9618/31/O/N/24 original Q10 Structured · 9 marks Worked solution (a) Read each diagram and write it in BNF. <operator> ::= + | – | * | / <label> ::= <letter><digit> | <letter><digit><digit> <equation> ::= <label> = <label><operator><label> <operator> correct: any of the four symbols [1] <label> is a letter, then a digit, then an optional second digit [1] <equation> first part: <label> = [1] <equation> second part: <label><operator><label> [1] (b)(i) Draw the diagram in this order: start, then a choice of letter or symbol , then digit , then symbol with a loop-back route so that a second symbol is allowed, then the end. Label it password. Starts with a choice of letter or symbol [1] Ends with one or two symbols (a bypass or loop) [1] Digit in the middle, all connections and the label correct [1] (b)(ii) <password> ::= <letter><digit><symbol> | <letter><digit><symbol><symbol> | <symbol><digit><symbol> | <symbol><digit><symbol><symbol> First alternative <password> ::= <letter><digit><symbol> correct [1] The other three alternatives correct [1] A shorter way also scores: write <first> ::= <letter>|<symbol>, <last> ::= <symbol>|<symbol><symbol> and <password> ::= <first><digit><last>. All three lines correct scores 2 marks; any two lines correct scores 1 mark. KEY IDEA BNF lists alternatives with | and sequences by writing items side by side; an optional item needs two alternatives. TOTAL 9 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by Craig'n'Dave. Tap the picture to open it on YouTube.