Lesson 4.4.3.1

4.4.3.1 Backus-Naur Form and syntax diagrams Quiz: AQA Computer Science, Unit 4

20 questions

In partnership with Revision Ninja

Lesson 4.4.3.1, Backus-Naur Form and syntax diagrams: 20 multiple choice questions for the AQA Computer Science (7517), Unit 4: Theory of computation, written with Revision Ninja.

Host it live on the board and students join with a game code on their own devices, or revise alone with Free Play. The answers are revealed in the game.

Host this setFree Play

The 20 questions

  1. What is Backus-Naur Form (BNF) used for?

    • Describing the syntax of a language with production rules
    • Measuring processor speed
    • Sorting lists of numbers
    • Drawing pictures of the computer hardware used to run compiled programs
  2. In BNF, what does the symbol ::= mean?

    • Is an integer division
    • Is greater than or equal to the number of rules in the grammar
    • Is defined as, or can be replaced by
    • Is a comment
  3. In BNF, what do angle brackets such as <digit> enclose?

    • Numbers only
    • Final output characters only
    • Comments that the compiler ignores when it builds the final output file
    • Non-terminal symbols that can be replaced by further rules
  4. What is a syntax diagram?

    • A graphical representation of the syntax rules of a language
    • A map of network routes
    • A chart of program running times
    • A diagram of computer hardware
  5. Why can BNF represent some languages that regular expressions cannot?

    • It can only handle numbers
    • It is faster to process
    • Its recursive rules allow nested structures of unbounded depth
    • It uses more colours in its notation
  6. With the rule <integer> ::= <digit> | <integer><digit> and <digit> from 0 to 9, which string is a valid integer?

    • -5
    • 12a
    • an empty string
    • 2024
  7. Using the grammar <s> ::= 01 | 0<s>1, which string is generated?

    • 0101
    • 0110
    • 1100
    • 0011
  8. In the grammar <s> ::= 01 | 0<s>1, how many production steps are needed to derive 000111?

    • 4
    • 2
    • 6
    • 3
  9. Which production rule describes one or more letters?

    • <word> ::= <word>
    • <word> ::= <letter> | <word><letter>
    • <word> ::= 1
    • <word> ::= <letter>+<letter>
  10. With the rule <expr> ::= <number> | <expr>+<expr> and <number> any integer, which string is valid?

    • +1
    • 1+
    • 1 2
    • 1+2+3
  11. What is a production rule in a grammar?

    • A rule that deletes all non-terminals
    • A rule that counts characters
    • A rule that sorts all the symbols in a string into alphabetical order
    • A rule that replaces a non-terminal by terminals and non-terminals
  12. In the grammar <s> ::= 01 | 0<s>1, which string cannot be generated?

    • 0110
    • 01
    • 000111
    • 0011
  13. What is a terminal symbol in BNF?

    • A symbol that is always replaced by another rule and never appears in the output
    • A symbol that marks the end of a file
    • A symbol used only for comments
    • A symbol that appears in the final strings and cannot be replaced further
  14. A grammar generates the strings aabb, ab and so on from <s> ::= a<s>b | ab. Which string is generated?

    • abab
    • aabb
    • ba
    • aab
  15. With <p> ::= a | b | a<p>a | b<p>b, which string is generated?

    • aba
    • abb
    • aa
    • ab
  16. Which construct is most naturally specified in BNF rather than with a regular expression?

    • A string of exactly four characters
    • A fixed list of three colours
    • A single optional minus sign
    • Arithmetic expressions with nested brackets
  17. What does it mean for a grammar to be ambiguous?

    • The grammar has no production rules at all and therefore produces nothing
    • Some string has more than one valid parse tree
    • The grammar cannot generate any strings
    • The grammar uses only terminals
  18. How many characters does the string derived by applying 0<s>1 twice and then 01 contain, using <s> ::= 01 | 0<s>1?

    • 6
    • 4
    • 8
    • 5
  19. A syntax diagram contains a loop that returns back before an exit. What does the loop represent?

    • Repetition of an element that may occur several times
    • An error that must be fixed
    • A comment in the code
    • A variable that is undefined
  20. Which statement about BNF and regular expressions is correct?

    • BNF and regular expressions are unrelated
    • BNF can only describe finite languages
    • Regular expressions can describe any language that BNF can describe
    • BNF can describe every regular language and also some languages that regular expressions cannot

All AQA Computer Science quizzes