Examples of DFA
Deterministic Finite Automata (DFA) are a fundamental concept in automata theory and formal languages, widely used in computer science, compiler design, pattern matching, and lexical analysis. This article explains DFA with clear examples, making it easy for students and beginners to understand.
A Deterministic Finite Automaton (DFA) is a finite state machine that accepts or rejects strings of symbols by transitioning through a finite number of states.
A DFA is defined by a 5-tuple:
DFA = (Q, Σ, δ, q₀, F)
Where:
-
Q = finite set of states
-
Σ = input alphabet
-
δ = transition function (Q × Σ → Q)
-
q₀ = initial state
-
F = set of accepting (final) states
In a DFA, for every state and input symbol, there is exactly one transition.
DFA Question Category 1: Accept Only the Given Input
In this section, a DFA accepts only one specific input string and rejects all other strings. For example,
- Accepts only the string “aaab”
- Accepts only the string “01”
DFA Example 01:Draw a DFA which accept only input string “1”
Over input alphabets ∑ = {0,1}
The explanation of the above DFA is given below
- States = {q0, q1, q2}
- Input Alphabet = {0,1}
- Initial State = q0
- Final State = q1
- Dead State = q2
Transition Function (δ) for all input alphabets (“0,1”) is defined in the following DFA Transition Table

DFA Example 02:Draw a DFA which accept only input string “a”
Over input alphabets ∑ = {a,b,c}
The explanation of the above DFA is given below
- States = {q0, q1, q2}
- Input Alphabet = {a,b,c}
- Initial State = q0
- Final State = q1
- Dead State = q2
Transition Function (δ) for all input alphabets (“a,b,c”) is defined in the following DFA Transition Table

DFA Example 03:Draw a DFA which accept only input string “b”
Over input alphabets ∑ = {a,b,c,d}

The explanation of the above DFA is given below
- States = {q0, q1, q2}
- Input Alphabet = {a,b,c,d}
- Initial State = q0
- Final State = q1
- Dead State = q2
Transition Function (δ) for all input alphabets (“a,b,c,d”) is defined in the following DFA Transition Table

DFA Example 04:Draw a DFA which accept only input string “10”
Over input alphabets ∑ = {0,1}

The explanation of the above DFA is given below
- States = {q0, q1, q2,q3}
- Input Alphabet = {0,1}
- Initial State = q0
- Final State = q2
- Dead State = q3
Transition Function (δ) for all input alphabets (“0,1”) is defined in the following DFA Transition Table

DFA Example 05:Draw a DFA which accept only input string “bc”
Over input alphabets ∑ = {a,b,c}

The explanation of the above DFA is given below
- States = {q0, q1, q2,q3}
- Input Alphabet = {a,b,c}
- Initial State = q0
- Final State = q2
- Dead State = q3
Transition Function (δ) for all input alphabets (“a,b,c”) is defined in the following DFA Transition Table

DFA Example 06:Draw a DFA which accept only input string “abcd”
Over input alphabets ∑ = {a,b,c,d,e}

The explanation of the above DFA is given below
- States = {q0, q1, q2,q3,q4,q5}
- Input Alphabet = {a,b,c,d,e}
- Initial State = q0
- Final State = q4
- Dead State = q5
Transition Function (δ) for all input alphabets (“a,b,c,d,e”) is defined in the following DFA Transition Table

DFA Example 07:Draw a DFA which accept only input string “11001”
Over input alphabets ∑ = {0,1}

The explanation of the above DFA is given below
- States = {q0, q1, q2,q3,q4,q5,q6}
- Input Alphabet = {0,1}
- Initial State = q0
- Final State = q5
- Dead State = q6
Transition Function (δ) for all input alphabets (“0,1”) is defined in the following DFA Transition Table

DFA Example 08: Draw a DFA which accept only input string “abacba”
Over input alphabets ∑ = {a,b,c}

The explanation of the above DFA is given below
- States = {q0, q1, q2,q3,q4,q5,q6,q7}
- Input Alphabet = {a,b,c}
- Initial State = q0
- Final State = q6
- Dead State = q7
Transition Function (δ) for all input alphabets (“a,b,c”) is defined in the following DFA Transition Table

DFA Example 09:

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3, q4, q5}
- Input Alphabet = {0,1}
- Initial State = q0
- Final State = q4
- Dead State = q5
DFA Example: 02

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3,}
- Input Alphabet = {1,0}
- Initial State = q0
- Final State = q2
- Dead State = q3
DFA Example: 03

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3, q4,}
- Input Alphabet = {0,1}
- Initial State = q0
- Final State = q3
- Dead State = q4
DFA Example: 04 (start with)

The explanation of the above DFA is given below
- States = {q0, q1, q2}
- Input Alphabet = {1,0}
- Initial State = q0
- Final State = q1
- Dead State = q2
DFA Example: 05 (similar to 3)

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3, q4}
- Input Alphabet = {1,0}
- Initial State = q0
- Final State = q3
- Dead State = q4
DFA Example: 06 (similar to 2)

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3}
- Input Alphabet = {1,0}
- Initial State = q0
- Final State = q2
- Dead State = q3
DFA Example: 07

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3, q4, q5}
- Input Alphabet = {1,0}
- Initial State = q0
- Final State = q4
- Dead State = q5
DFA Example: 08

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3, q4, q5}
- Input Alphabet = {0,1}
- Initial State = q0
- Final State = q4
- Dead State = q5
DFA Example: 09

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3, q4, q5}
- Input Alphabet = {0,1}
- Initial State = q0
- Final State = q4
- Dead State = q5
DFA Example: 10

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3}
- Input Alphabet = {1,0}
- Initial State = q0
- Final State = q2
- Dead State = q3
DFA Example: 11

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3}
- Input Alphabet = {0,1}
- Initial State = q0
- Final State = q2
- Dead State = q3
DFA Example: 12

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3, q4, q5}
- Input Alphabet = {1,0}
- Initial State = q0
- Final State = q4
- Dead State = q5
DFA Example: 13

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3, q4, q5}
- Input Alphabet = {1,0}
- Initial State = q0
- Final State = q4
- Dead State = q5
DFA Example: 14

The explanation of the above DFA is given below
- States = {q0, q1}
- Input Alphabet = {0,1}
- Initial State = q0
- Final State = q1
DFA Example: 15

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3}
- Input Alphabet = {1,0}
- Initial State = q0
- Final State = q4
- Dead State = q3
DFA Example: 16

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3, q4, q5}
- Input Alphabet = {a,b}
- Initial State = q0
- Final State = q4
- Dead State = q5
DFA Example: 17

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3}
- Input Alphabet = {a,b}
- Initial State = q0
- Final State = q2
- Dead State = q3
DFA Example: 18

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3}
- Input Alphabet = {b,a}
- Initial State = q0
- Final State = q2
- Dead State = q3
DFA Example: 19

The explanation of the above DFA is given below
- States = {q0, q1, q2, q3, q4}
- Input Alphabet = {b,a}
- Initial State = q0
- Final State = q3
- Dead State = q4
DFA Example: 20


The explanation of the above DFA is given below
- States = {q0, q1, q2}
- Input Alphabet = {0,1}
- Initial State = q0
- Final State = q2

