Question 6

AQA Computer Science June 2025 Paper 1 (7517/1)A level14 marks

On the specification

6.1
4.4 Theory of computation
6.2
4.4 Theory of computation
6.3
4.4 Theory of computation
6.4
4.4 Theory of computation
6.5
4.4 Theory of computation
6.6
4.4 Theory of computation
6.7
4.4 Theory of computation
6.8
4.4 Theory of computation
Question text

6 This question is about the CheckIfUserInputValid subroutine. Figure 5 shows a finite state machine (FSM) represented as a state transition diagram. The FSM is equivalent to the regular expression in the CheckIfUserInputValid subroutine. Figure 5 6.1 Complete the unshaded cells in Table 3 to represent the FSM in Figure 5 as a state transition table. Part of the first row has been completed for you. Table 3 Initial state Input(s) New state 0–9 Copy the contents of the unshaded cells in Table 3 into the table in your Electronic Answer Document. [2 marks] Figure 6 and Figure 7 show two attempts to represent the regular expression in the CheckIfUserInputValid subroutine using a state transition diagram. There are errors in both diagrams, as the FSM will either accept some strings that do not match the regular expression or not accept some strings that do match the regular expression. Figure 6 Figure 7 6.2 Explain which strings accepted by the FSM in Figure 5 are not accepted by the FSM in Figure 6. [2 marks] 6.3 Explain which strings accepted by the FSM in Figure 7 are not accepted by the FSM in Figure 5. [2 marks] 6.4 Explain the purpose of the metacharacter $ in the regular expression in the CheckValidNumber subroutine. [1 mark] 6.5 Explain the difference between the metacharacters * and ? in regular expressions. [1 mark] 6.6 A regular expression can be used to describe a set. State two properties of sets that do not have to be true for a list. [2 marks] Infix expressions can normally use brackets. The infix expressions entered by the user in the Skeleton Program cannot use brackets. 6.7 Explain why a regular expression could not be used to check if an infix expression entered by the user was valid if the infix expression was allowed to contain brackets. [1 mark] Figure 8 contains three rules for a language represented using Backus-Naur Form (BNF). Figure 8 <operator> ::= +|–|*|/ <digit> ::= 0|1|2|3|4|5|6|7|8|9 <number> ::= <digit>|<digit><number> 6.8 Add BNF rule(s) to the language shown in Figure 8 for an expression. An expression should match all infix expressions currently accepted by the Skeleton Program and also allow the infix expression to use brackets. [3 marks]