We will follow a similar approach to previous exercises to solve this exercise.
Let’s define 5 states as follows:
- S0, the initial state
- S1 is the state when the automata read exactly one 0
- S2 is the state when the automata read exactly two 0s
- S3 is the state when the automata read exactly three 0s. This is our final state because the automaton should recognize only strings with exactly three 0s.
- S4 is the state when the automaton read more than three 0s.
After the definition of the previous states, we can also define the following transitions:
- From the initial state with a 1, there is no need to change to a different state.
- Reading a 0 at the initial state, the new state will be S1 (the automaton read exactly one 0).
- At S1, reading a 0, the automaton will go to the next state S2 (the automaton read exactly two 0s).
- At S1, reading a 1, the automaton will stay in the same state.
- At S2, reading a 0, the automaton will go to the state S3. The automaton read exactly three 0s. Therefore, this one is a final state.
- At S2, reading a 1, the automaton will stay in the same state.
- At S3, reading a 0, the automaton will go to the state S4. At this point, the string cannot be recognized by this automaton. Therefore, this state is not final and whatever bit comes next, the automaton will stay in the same state.
We can also specify the transition function using the table below. Don’t forget to specify that S3 is the final state if you use a state table.
f | ||
States | 1 | 0 |
S0 | S0 | S1 |
S1 | S1 | S2 |
S2 | S2 | S3 |
S3 | S3 | S4 |
S4 | S4 | S4 |
Similar exercises:
- Construct a deterministic finite-state automaton that recognizes the set of all bit strings that do not contain three consecutive 0s.
- Construct a deterministic finite-state automaton that recognizes the set of all bit strings beginning with 01
- Construct a deterministic finite-state automaton that recognizes the set of all bit strings that end with 10
- Construct a deterministic finite-state automaton that recognizes the set of all bit strings that contain the string 101