- 2074 Asoj
DFA starts or ends with 01
Short answer
DFA for start with 01 or end with 01: states q0 (start), a (saw 0), F (trap for start-01), N (ends in 1), Z (ends in 0), E (ends in 01). Transition: q0-0→a, q0-1→N; a-0→Z, a-1→F; N-0→Z, N-1→N; Z-0→Z, Z-1→E; E-0→Z, E-1→N; F loops. Accept F, E. Example: '01110' → F; '1101' → E; '1100' → Z rejected.
What is the significance of finite automata? Design a DFA that accepts the strings over the alphabet Σ = {0,1} that either start with 01 or end with 01. Hence test your design for any two strings.
Significance of finite automata
- They are the simplest model of computation (a machine with finite memory) and define the regular languages.
- They are used in lexical analysers (tokenisers), text search and pattern matching, network protocols, hardware controllers and vending/traffic controllers.
- They are the base for studying more powerful machines (pushdown automata, Turing machines) and show what can be done with a fixed amount of memory.
DFA: strings that start with 01 or end with 01
Idea. After reading a prefix 01, accept everything (a final trap state F). Otherwise keep track of the "ends with 01" condition using three states:
- N: the last symbol is 1 (or nothing relevant yet),
- Z: the last symbol is 0,
- E: the last two symbols are 01 (final).
States: q0 (start), a (read "0" first), F (prefix 01 seen), N, Z, E.
M = ({q0, a, F, N, Z, E}, {0,1}, δ, q0, {F, E})
| State | 0 | 1 |
|---|---|---|
| → q0 | a | N |
| a | Z | F |
| *F | F | F |
| N | Z | N |
| Z | Z | E |
| *E | Z | N |
q0 ─0─► a ─1─► ((F)) ↻0,1
│ └0─► Z
└1─► N ─0─► Z ─1─► ((E))
↻1 ↻0 │0 -> Z
│1 -> N
(N -1-> N, N -0-> Z, Z -0-> Z, Z -1-> E)
Edges: q0 –0→ a, q0 –1→ N, a –0→ Z, a –1→ F, N –0→ Z, N –1→ N, Z –0→ Z, Z –1→ E, E –0→ Z, E –1→ N, F loops.
Testing
- "01110" (starts with 01): q0 →0 a →1 F →1 F →1 F →0 F. Accepted.
- "1101" (ends with 01): q0 →1 N →1 N →0 Z →1 E. Accepted.
- "1100" (neither): q0 → N → N → Z → Z. Z is not final. Rejected.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Configuration of DFA; DFA with 01 and 10 · Theory of Computation, chapter 2
- DFA for {00}*{11}* language · Theory of Computation, chapter 2
- DFA: even a and odd b · Theory of Computation, chapter 2
- Convert ε-NFA (q0..q4) to DFA · Theory of Computation, chapter 2 · asked 2×
- Convert NFA (q0..q4, 0/1) to DFA · Theory of Computation, chapter 2 · asked 2×
- Convert NFA (q0,q1,q2) to DFA · Theory of Computation, chapter 2
- Design NFA for strings ending with aba · Discrete Structure, chapter 2
- Design FSA for strings beginning with baa · Discrete Structure, chapter 2
- Define FSM; design FSA with two consecutive a's · Discrete Structure, chapter 2 · asked 4×
- Differentiate Finite State Machine and Automata · Discrete Structure, chapter 2 · asked 2×