Lesson 4.4.2.3

4.4.2.3 Regular expressions Quiz: AQA Computer Science, Unit 4

20 questions

In partnership with Revision Ninja

Lesson 4.4.2.3, Regular expressions: 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 a regular expression?

    • A compact way of describing a set of strings
    • A compiled program
    • A hash function
    • A type of sorting algorithm
  2. What does the metacharacter * mean in a regular expression?

    • Exactly one repetition, which is required once and never more
    • Alternation
    • Zero or more repetitions
    • One or more repetitions
  3. What does the metacharacter + mean in a regular expression?

    • One or more repetitions
    • Grouping
    • Zero or more repetitions
    • Optional
  4. What does the metacharacter ? mean in a regular expression?

    • Two repetitions of the preceding item, one after the other
    • The start of a string
    • Any single character
    • Zero or one repetition, meaning optional
  5. What does the metacharacter | mean in a regular expression?

    • Alternation, meaning or
    • Concatenation
    • Grouping
    • Repetition
  6. Which set of strings does a(a|b)* describe?

    • Strings of even length only
    • Strings containing no a
    • Strings beginning with a, followed by any number of a or b
    • Strings containing no a at all and any number of b characters after it
  7. Which string is matched by a(a|b)*?

    • aba
    • bba
    • ba
    • b
  8. Which string is matched by the regular expression ab+?

    • ba
    • a
    • bb
    • abbb
  9. Which string is matched by the regular expression colou?r?

    • colouurr
    • color
    • colr
    • colouur
  10. Which string is matched by (01)*?

    • 010
    • 0110
    • 1010
    • 0101
  11. Which string is matched by 0(0|1)*0?

    • 0111
    • 1001
    • 0110
    • 0101
  12. Which regular expression matches one or more a followed by an optional b?

    • a*b+
    • a|b?
    • (ab)+
    • a+b?
  13. Which string is matched by a(b|c)?

    • ab
    • a
    • b
    • abc
  14. Regular expressions and finite state machines are what?

    • Equivalent ways of defining a regular language
    • Only used for graphics
    • Methods of sorting lists
    • Unrelated concepts
  15. Which of these languages is regular?

    • Balanced brackets of any depth
    • Palindromes over the alphabet a and b
    • The strings 0^n 1^n for n of at least 1
    • All strings of 0s and 1s ending in 1
  16. Is the language {0^n 1^n | n >= 1} regular, and why?

    • Yes, because the language is finite
    • No, an FSM would need to count an unbounded number of 0s
    • Yes, because it has a regular expression
    • No, because it contains the symbol 1
  17. Which description gives a machine that accepts exactly the language of a(a|b)*?

    • A start state that loops on b and an accepting state with a dead end on every input
    • Two states with no transitions
    • A start state with an a transition to an accepting state that loops on a and b
    • An accepting start state that rejects a
  18. Which regular expression matches binary strings containing at least one 1?

    • 0*
    • (0|1)*1(0|1)*
    • 1+0+
    • (0|1)*
  19. Which string is matched by both a* and (a|b)+?

    • ab
    • b
    • aa
    • ba
  20. Which example best illustrates the metacharacters used in a regular expression for string matching?

    • Compiling to machine code
    • Searching a binary tree
    • Grouping with brackets, alternation with a bar, and repetition with star or plus
    • Sorting with a bubble pass

All AQA Computer Science quizzes