Theory of computation · A level · AQA 7517 4.4.2.1 · about 20 min
States, transitions and accepting states; state transition diagrams and tables; tracing an FSM and running one from a table.
[1 mark]In a state transition diagram for an FSM with no output, what does a double circle show?
[1 mark]The parity FSM starts in S0 (accepting). A 0 keeps the state and a 1 swaps S0 and S1. Which state is it in after reading 11010?
[1 mark]An FSM has 4 states and an input alphabet of 3 symbols. How many rows does its complete state transition table have?
[1 mark]An FSM has no transition shown for a 0 in state S0. What normally happens if it reads a 0 in S0?
[1 mark]What does this program print?
table = {("S0", "a"): "S1", ("S0", "b"): "S0", ("S1", "a"): "S1", ("S1", "b"): "S0"}
state = "S0"
for symbol in "abba":
state = table[(state, symbol)]
print(state, end=" ")
print(state == "S1")Design a finite state machine that accepts binary strings that end in 01, store it as a transition table, and run it.
- table is a dictionary: each key is a pair (state, symbol), where symbol is the string "0" or "1", and each value is the next state. Include a transition for every state with both symbols.
- The machine must decide by following transitions one symbol at a time. Do not look at the end of the string directly.
- For each string in tests, in order, print one line: the string, a space, then accept or reject. For example 1101 accept. Six lines in all.
Work out what each state needs to remember before you write the table: how much of 01 has the machine just seen?
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
tests = ["01", "1101", "0110", "1", "00101", "0100"]
table = {}Plan your program here, then type it in and press Run.
00 anywhere. Does it need a trap state, or a state it can never leave?