Shortest word of an automaton
A breadth-first search from the start state finds the shortest accepted word and also settles whether the language is empty.
Rules
- Breadth-first search from the start state
- The first accepting state reached gives the length
- No accepting state reachable: empty language
Your turn
Three problems on this topic. The software checks your answer exactly.
- 1 · Shortest word
- 2
- 3
How long is the shortest word the automaton accepts?
| δ | a | b |
|---|---|---|
| → q0 | q0 | q1 |
| q1 | q2 | q0 |
| *q2 | q3 | q3 |
| q3 | q0 | q1 |
Length (ε has length 0)
Worked example
How long is the shortest word the automaton accepts?
| δ | a | b |
|---|---|---|
| → q0 | q3 | q0 |
| q1 | q0 | q2 |
| *q2 | q0 | q3 |
| q3 | q1 | q2 |
Worked solution
- 1Breadth-first search from q0: the shortest word is ab.
- 2q0 → q3 → q2
Typical mistake: If the start state is accepting, the answer is 0.
Common questions
Can the answer be 0?
Yes, if the start state is accepting. Then the empty word is in the language.
