Full Marks

A-level Computer Science Year 12 · Topic 6

Theory of computation

The theory of computation asks what computers can do in principle, and what they can never do.

We will use finite state machines, set notation, regular expressions and Backus Naur form.

Then we meet Turing machines, the limits of computation, tractable and intractable problems, and the halting problem.

In this topic

  1. 6.1Finite state machines and state transition diagrams/tablesFree below · 22 questions
  2. 6.2Finite state machines with output (Mealy machines)Open in Full Marks · 24 questions
  3. 6.3Set theory and notation for regular languagesOpen in Full Marks · 16 questions
  4. 6.4Regular expressions and regular languagesOpen in Full Marks · 17 questions
  5. 6.5Context-free languages, BNF and syntax diagramsOpen in Full Marks · 20 questions
  6. 6.6Turing machines and the universal Turing machineOpen in Full Marks · 19 questions
  7. 6.7Classification of problems, tractability and the halting problemOpen in Full Marks · 25 questions

6.1 · Free notes

Finite state machines and state transition diagrams/tables

Diagram: Finite state machines and state transition diagrams/tables

Key points

In more detail

Practice

Finite state machines and state transition diagrams/tables: 10 questions

Pick an answer to check it, or open the answer for the explanation.

1. FSM: start state S0 (accepting). Input 1 switches between S0 and S1; input 0 keeps the current state. Which string is accepted?

  1. 0110
  2. 111
  3. 10
  4. 1101
Show answer

A: 0110. 0110 contains two 1s, so the machine switches S0→S1→S0 and ends in S0, which is accepting. 1101 and 111 have three 1s, and 10 has one.

2. Start S0, accepting S2. Table: S0: a→S1, b→S0. S1: a→S2, b→S0. S2: a→S2, b→S2. Which string is accepted?

  1. abaa
  2. bbb
  3. abab
  4. baba
Show answer

A: abaa. abaa gives S0→S1→S0→S1→S2, which is accepting. abab and baba end in S0 and S1, and bbb stays in S0. The machine accepts strings containing aa.

3. Which language can NOT be recognised by a finite state machine?

  1. Strings of a's of even length
  2. Binary strings ending in 01
  3. Strings of n a's followed by n b's
  4. Binary strings containing 111
Show answer

C: Strings of n a's followed by n b's. aⁿbⁿ needs the machine to count n without limit, but an FSM has only finitely many states. The other three languages are regular.

4. Which statement about a deterministic FSM is correct?

  1. Each state has exactly one transition for each input symbol
  2. A state may have two transitions for the same symbol
  3. It stores input on an unlimited stack
  4. It must have exactly one accepting state
Show answer

A: Each state has exactly one transition for each input symbol. Deterministic means the next state is fully determined by the current state and the input symbol. There can be several accepting states, or none, and there is no stack.

5. An FSM accepts the empty string ε if and only if which condition holds?

  1. The machine has no accepting states
  2. The start state has a loop on every symbol
  3. The machine has an even number of states
  4. The start state is an accepting state
Show answer

D: The start state is an accepting state. With no input symbols read, the machine is still in its start state. So ε is accepted only if the start state is accepting.

6. A deterministic FSM has 5 states and the input alphabet {0, 1}. How many next-state entries are in its complete transition table?

  1. 5
  2. 25
  3. 7
  4. 10
Show answer

D: 10. There is one entry for every (state, symbol) pair: 5 states × 2 symbols = 10 entries.

7. An FSM must accept binary strings over {0,1} that end in 1. What is the minimum number of states needed?

  1. 1
  2. 2
  3. 3
  4. 4
Show answer

B: 2. Two states are enough: one for 'last symbol was not 1' (start) and one for 'last symbol was 1' (accepting). Each state needs only 0 and 1 transitions.

8. Start S0 (accepting). Input 1 toggles S0 and S1; input 0 keeps the state. After reading 10110, what happens?

  1. Rejected, ends in S1
  2. Rejected, ends in S0
  3. Accepted, ends in S0
  4. Accepted, ends in S1
Show answer

A: Rejected, ends in S1. 10110 has three 1s, so the machine toggles three times: S0→S1→S0→S1. It ends in S1, which is not accepting, so the string is rejected.

9. Which is NOT part of the definition of a basic FSM without output?

  1. A start state
  2. A finite set of states
  3. An input alphabet
  4. A tape the machine can overwrite
Show answer

D: A tape the machine can overwrite. An FSM has states, an alphabet, transitions, a start state and accepting states. A rewritable tape belongs to a Turing machine.

10. Which class of languages is recognised by finite state machines?

  1. Regular languages
  2. All context-free languages, such as balanced brackets
  3. Any language a Turing machine can decide
  4. All languages over {0,1}
Show answer

A: Regular languages. FSMs recognise exactly the regular languages, which are also described by regular expressions. Balanced brackets need a stack.

Keep going in Full Marks

Full Marks has 22 questions on Finite state machines and state transition diagrams/tables (12 more than here), set out in practice levels. You also get notes and 3D models for all 7 subtopics of Theory of computation, plus games, timed exams and past papers.

On your exam board

Not in the Cambridge specification.

All A-level Computer Science Year 12 topics