Tutorial 3 Discussion Document - Batch 03
Tutorial 3 Discussion Document - Batch 03
Example
Give a regular expression and an equivalent NFA for the language over {a, b} that starts with aa
and contains the substring ba. Convert the NFA you obtained to a DFA.
NFA:
a, b a, b
a a b a
q0 q1 q2 q3 q4
1) Every state in the DFA should have an outgoing arrow for every input alphabet.
2) A state should not have redundancy or choice for an input alphabet.
DFA: aaabbaaa a b a, b
a a b a
3)
q0 q1 q2 q3 q4
4)
b
b
a, b
1) Build an NFA (separately for each) that accepts the following languages.
a) Strings over the digits 0-9 which contain at least three 1’s.
b) Strings over the digits 0-9 which contain 777 somewhere in the string.
e.g., strings are: 777, 012345677789, 77710, 7777777777, 012377745689077798765 etc.
c) Strings over the digits 0-9 which do not contain 777 anywhere in the string.
e.g., strings are 0, 1, 2, 3, 7, 07, 70, 77, 1234567890123456, 1237456770129875477.
0-6, 8-9
7 7
q0\ q0
q1 q2
0-6, 8-9
0-6, 8-9
a) Strings over the digits 0-9 which contain at least three 1’s.
0, 2 - 9 0, 2 - 9 0, 2 - 9 0-9
1 1 1
q0 q1 q2 q3
b) Strings over the digits 0-9 which contain 777 somewhere in the string.
c) Strings over the digits 0-9 which do not contain 777 anywhere in the string.
7 7 7
\ q0 q0
q1 q2 q3
0-6, 8-9
0-6, 8-9
RE: a+b+c+
a b c
a b c
q0 q1 q2 q3
a, b , c
b) The set of strings over {a, b, c} that begin with a, contain exactly two consecutive b’s and end
with cc.
c) The set of strings over {a, b, c} that do not contain the substring aa.
Please solve this Question as part of your Assignment-1, Tutorial 3.
For the above question NFA is easy to construct. However, writing the RE would be tricky. Do
not worry. Just try. Otherwise, after the tutorial 3 assignment submission I’ll discuss in class.
You will not lose marks for the RE.