Theory of Computing
Lec-2
Type-1 Problems
In Type-01 problems, we will discuss the construction of DFA for languages consisting of strings ending with a particular
substring.
Steps To Construct DFA-
Following steps are followed to construct a DFA for Type-01 problems-
Step-01:
Determine the minimum number of states required in the DFA.
Draw those states.
Use the following rule to determine the minimum number of states-
RULE
Calculate the length of substring.
All strings ending with ‘n’ length substring will always require minimum (n+1) states in the DFA.
Step-02:
Decide the strings for which DFA will be constructed.
Step-03:
Construct a DFA for the strings decided in Step-02.
Remember the following rule while constructing the DFA-
RULE
While constructing a DFA,
Always prefer to use the existing path.
Create a new path only when there exists no path to go with.
Step-04:
•Send all the left possible combinations to the starting state.
•Do not send the left possible combinations over the dead state.
DFA ( Example-1)
L1=Set of all string that start with 0
Possible cases = {0,00,01,000, 001 ………}
E.g. 001
0 0,1
0 0 1
1
0,1
E.g 101
Dead or trap state
1 0 1
DFA (Example-2)
Draw a DFA for the language accepting strings ending with ’01’ over input alphabets ∑ = {0, 1}
Solution-
Regular expression for the given language = (0 + 1)*01
Step-01:
•All strings of the language ends with substring “01”.
•So, length of substring = 2.
Thus, Minimum number of states required in the DFA = 2 + 1 = 3.
It suggests that minimized DFA will have 3 states.
Step-02:
We will construct DFA for the following strings-
01
001
0101
Step-03:
The required DFA is-
DFA (Example-3)
Draw a DFA for the language accepting strings ending with ‘abb’ over input alphabets ∑ = {a, b}
Solution-
Regular expression for the given language = (a + b)*abb
Step-01:
All strings of the language ends with substring “abb”.
So, length of substring = 3.
Thus, Minimum number of states required in the DFA = 3 + 1 = 4.
It suggests that minimized DFA will have 4 states.
DFA (Example-3)
Step-02:
We will construct DFA for the following strings-
abb
aabb
ababb
abbabb
Step-03:
The required DFA is-
Practice Session
Draw a DFA for the language accepting strings ending with ‘abba’ over input alphabets ∑ = {a, b}
Practice Session Solution
Draw a DFA for the language accepting strings ending with ‘abba’ over input alphabets ∑ = {a, b}
We will construct DFA for the following strings-
abba
aabba
ababba
abbabba
abbaabba
Type-2 Problems
Draw a DFA for the language accepting strings starting with ‘a’ over input alphabets ∑ = {a, b}
Solution-
Regular expression for the given language = a(a + b)*
The required DFA is-
We will construct DFA for the following strings-
a
aa
Type-2 Problems
In Type-02 problems, we will discuss the construction of DFA for languages consisting of strings starting with a
particular substring.
Draw a DFA for the language accepting strings starting with ‘ab’ over input alphabets ∑ = {a, b}
Solution-
Regular expression for the given language = ab(a + b)*
We will construct DFA for the following strings-
ab
aba
abab
Practice Session
Draw a DFA for the language accepting strings starting with ‘101’ over input alphabets ∑ = {0, 1}
Practice Session Solution
Draw a DFA for the language accepting strings starting with ‘101’ over input alphabets ∑ = {0, 1}
We will construct DFA for the following strings-
101
1011
10110
101101
End