Question 2
AQA Computer Science November 2020 Paper 1 (7517/1)A level8 marks
On the specification
- 2.1
- 4.4 Theory of computation
- 2.2
- 4.4 Theory of computation
- 2.3
- 4.4 Theory of computation
- 2.4
- 4.4 Theory of computation
- 2.5
- 4.4 Theory of computation
- 2.6
- 4.4 Theory of computation
Question text
2 A regular language is a language that can be defined by a regular expression. 2.1 Complete the unshaded cells of Table 1 to show which of the statements about regular languages are true and which are false. Table 1 Statement True or False? All regular languages can be represented using a finite state machine without outputs. The set of strings defined by a regular language is always finite in size. There are some languages which can be represented in Backus- Naur Form (BNF) that are not regular languages. Copy the contents of the unshaded cells in Table 1 into the table in your Electronic Answer Document. [2 marks] Figure 2 shows a set of Backus-Naur Form (BNF) rules that are used to define a language. Figure 2 <sentence> ::= <np><v> <sentence> ::= <v><np> <np> ::= <d><n> <n> ::= human | dog | cat | baby <d> ::= a | the <v> ::= ate | slept | drank | cuddle <c> ::= and | but | or 2.2 There are two rules in Figure 2 with <sentence> on the left-hand side that are used to define what a valid sentence is in the language. Write a single rule that could replace these two rules. Your new rule must not change what a valid sentence is. [1 mark] 2.3 Complete the unshaded cells of Table 2 to show which of the strings are valid sentences for the language defined by the BNF rules in Figure 2 Table 2 String Valid sentence (Y/N)? cuddle the cat drank a human the cat slept cat or dog Copy the contents of the unshaded cells in Table 2 into the table in your Electronic Answer Document. [1 mark] 2.4 The sentence dog slept is not currently valid in the language defined in Figure 2 Change the language defined in Figure 2 by either adding or modifying exactly one rule so that dog slept is a valid sentence. You must not use the terminals dog or slept directly in the rule you write/change. [1 mark] The sentence the cat slept but the dog drank is not currently valid in the language defined in Figure 2. To allow this to be a valid sentence either one of the following two additional BNF rules could be used. <sentence> ::= <np><v><c><np><v> <sentence> ::= <sentence><c><sentence> 2.5 State the number of different sentences defined by the rule: <sentence> ::= <np><v><c><np><v> You should only use the rules in Figure 2 when working out your answer to this question. Do not include any additional sentences that your answer to question 02.4 would make valid. You can get full marks for this question for stating either the number of valid sentences or the full calculation needed to work out the number of valid sentences. You should show your working. [2 marks] 2.6 State how many more sentences are defined by the rule: <sentence> ::= <sentence><c><sentence> than by the rule: <sentence> ::= <np><v><c><np><v> [1 mark]