Revision Notes
OxfordAQA A-Level Computer Science (9645): Finite state machines (FSMs) – Revision Notes
Recall notes for OxfordAQA 9645 sub-topic 3.13.1: FSM diagrams and tables, accepting states, Mealy machines, traces, design steps and a self-test.
- Subject
- Computer Science
- Level
- A LEVEL
- Topic
- Topic 13 – Theory of computation
- Author
- Marlbridge Academic Team
- Updated
- Reviewed by
- Harris Khan (what this means)
Aligned to OxfordAQA A Level Computer Science (9645), 2024-onwards. Official specification .
Syllabus page (what it covers and how it is assessed): OxfordAQA A Level Computer Science.
Syllabus points this page covers
9645 (A Level)
- 3.13.1 Finite state machines (FSMs)
This page covers 1 of the 5 subtopics in topic 13, Theory of computation.
Found an error? Report a correction.
Need help with this topic? Request a free trial class for A Level Computer Science (9645).
These notes condense sub-topic 3.13.1 Finite state machines (FSMs) of OxfordAQA International AS and A-level Computer Science (9645), Version 1.1 (International A-level content in topic 3.13, examined in Unit 4). For worked machines and traces, see the FSM study guide, then practise with the FSM practice questions.
What the specification requires
- Draw and interpret simple state transition diagrams.
- Draw and interpret state transition tables.
- Do both for FSMs with output and without output.
- For FSMs with output, only Mealy machines are required, not Moore machines.
Key terms
| Term | Meaning |
|---|---|
| State | One of a finite number of conditions the machine can be in |
| Start state | The state before any input is read; shown with an arrow from nowhere |
| Accepting state | A state (double circle) in which a string is accepted if it ends there |
| Transition | A move from one state to the next, labelled with the input symbol |
| Trap state | A non-accepting state that only leads to itself |
| Mealy machine | An FSM that gives an output on each transition, labelled input / output |
| Accepted | The machine ends in an accepting state after the last symbol |
Two kinds of FSM
| Without output | With output (Mealy) | |
|---|---|---|
| Purpose | Decide if a string is in a language | Turn an input string into an output string |
| Accepting states | Yes | No |
| Arc label | input | input / output |
| Result | accepted or rejected | the output string |
| Length of result | none | same length as the input |
Worked reminder 1: ends in ab
| State | Input a | Input b |
|---|---|---|
| S0 (start) | S1 | S0 |
| S1 | S1 | S2 |
| S2 (accepting) | S1 | S0 |
| String | State path | Result |
|---|---|---|
bbab |
S0, S0, S0, S1, S2 | accepted |
aabb |
S0, S1, S1, S2, S0 | rejected |
ba |
S0, S0, S1 | rejected |
Only the last state matters. aabb visits S2 on the way but finishes in S0.
Worked reminder 2: even number of 1s
| State | Input 0 | Input 1 |
|---|---|---|
| S0 (start, accepting) | S0 | S1 |
| S1 | S1 | S0 |
1001 ends in S0: accepted. 111 ends in S1: rejected. The empty string is accepted because S0 is the start and accepting.
Worked reminder 3: Mealy machine
Each cell is next state / output. This machine outputs 1 when a 1 directly follows another 1.
| State | Input 0 | Input 1 |
|---|---|---|
| S0 (start) | S0 / 0 | S1 / 0 |
| S1 | S0 / 0 | S1 / 1 |
| Input | Path | Output |
|---|---|---|
0110111 |
S0, S0, S1, S1, S0, S1, S1, S1 | 0010011 |
101 |
S0, S1, S0, S1 | 000 |
1111 |
S0, S1, S1, S1, S1 | 0111 |
The output string is always the same length as the input string, and the path has one more entry than the input has symbols.
Reading a table
- Row = current state. Column = input symbol.
- The cell gives the next state (and, for a Mealy machine, the output after a slash).
- To trace: start in the start state, look up the first symbol, move, repeat.
Design steps
- List what the machine must remember. Each memory is a state.
- Name states by meaning.
- Mark the start state.
- Fill in every state and input pair. Add a trap state for strings that can never succeed.
- Mark the accepting states.
- Test with an accepted string, a rejected string and the empty string.
Table to arcs and back
A state transition table and a diagram hold the same information. To convert a table to arcs, write one arc for every cell.
| State | Input a | Input b |
|---|---|---|
| S0 (start) | S1 | S0 |
| S1 (accepting) | S1 | S0 |
Arcs: S0 –a–> S1, S0 –b–> S0, S1 –a–> S1, S1 –b–> S0. This machine accepts strings that end in a: for bba the path is S0, S0, S0, S1 (accepted), and for ab it is S0, S1, S0 (rejected). To convert the other way, make a row for every state and a column for every input symbol, and fill each cell from the arc that leaves that state on that symbol. If a cell would be empty, the machine is incomplete.
Exam traps
- Last state decides. Passing through an accepting state is not enough.
- Empty string. It is accepted only if the start state is accepting.
- Mealy output placement. Write it on the arc as input / output.
- Missing arcs. Every state needs an arc for every input symbol, or a stated rule for what happens.
- Moore machines are not required; do not draw outputs inside states.
- Counting limits. An FSM has finitely many states, so it cannot count without limit.
- Path length. For a string of n symbols the state path has n + 1 states.
Quick self-test
- What is the difference between a start state and an accepting state?
- How is an accepting state drawn?
- When is the empty string accepted?
- A Mealy machine reads 6 symbols. How long is its output?
- Using the “ends in ab” table, give the final state for
abab. - Is
ababaccepted? - Using the even-1s table, is
110011accepted? - Using the Mealy table above, give the output for
101. - What is a trap state for?
- How many states does a machine need to count a symbols modulo 4?
- Name the type of machine with output that the specification requires.
- Where is the output written on a Mealy diagram?
Answers
- The start state is where the machine begins; an accepting state is one in which a string ends to be accepted.
- As a double circle.
- When the start state is also an accepting state.
- 6 symbols.
- S2 (path S0, S1, S2, S1, S2).
- Yes, because S2 is accepting.
- Yes: four 1s, final state S0.
000- To reject any string that has already gone wrong, because it can never leave.
- Four.
- The Mealy machine.
- On each arc, written input / output.
Official syllabus
OxfordAQA International AS and A-level Computer Science (9645) specification, Version 1.1, for International AS exams May/June 2025 onwards and International A-level exams May/June 2026 onwards: sub-topic 3.13.1 Finite state machines (FSMs).
Related resources
-
Study guides
OxfordAQA A-Level Computer Science (9645): Regular expressions and regular languages
OxfordAQA 9645 sub-topic 3.13.2 in depth: regular expression metacharacters and classes, matching, converting between regular expressions and FSMs, regular languages.
Computer Science · OxfordAQA · A Level
Read guide -
Practice questions
OxfordAQA A-Level Computer Science (9645): Regular expressions and regular languages – Practice Questions
Ten original OxfordAQA 9645 questions on sub-topic 3.13.2 Regular expressions and regular languages: matching, writing expressions and converting to and from FSMs.
Computer Science · OxfordAQA · A Level
Try questions -
Revision notes
OxfordAQA A-Level Computer Science (9645): Regular expressions and regular languages – Revision Notes
Recall notes for OxfordAQA 9645 sub-topic 3.13.2: metacharacters, character classes, converting between regular expressions and FSMs, and a self-test.
Computer Science · OxfordAQA · A Level
Revise topic
Get free revision emails (optional)
Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.