Build a DFA for "ends with 01"
Standard · Match the pairs · about 6 min
Build a DFA over {0, 1} that accepts exactly the strings ending in 01. Use three states, each remembering how much of 01 the input ends with:
- q0: the input does not end with 0 or 01 (the start state)
- q1: the input ends with 0
- q2: the input ends with 01 (accept)
Match every state and symbol to the state the DFA moves to.
Example 1
Input:
{"text":"1101"}
Output:
accept
Your DFA must end in q2 after reading 1101.
Constraints
- Every state needs an arrow for 0 and an arrow for 1.
Learn the idea first: Finite automata: DFA and NFA, a visual lesson.
More Finite automata: DFA and NFA problems
- Accept or reject Warm-up
- Which language is this? Warm-up
- NFA to DFA Standard
- Run the DFA on 10010 Standard