CC Assignment2 PDF
CC Assignment2 PDF
0 1 2
ɛ ɛ
a b a
Transition Table:
a
States (ɛ-Closures) State (ɛ-Closures) after State (ɛ-Closures) after
reading 0 reading 1
0,1,2= A (initial state+ Final 0,1,2 = A 1,2 = B
State)
1,2 = B (final State) 2=C 1,2 = B
2 = C (final state) 2=C Ø=D
Ø=D Ø=D Ø=D
This study source was downloaded by 100000874451805 from CourseHero.com on 03-02-2024 08:00:39 GMT -06:00
https://www.coursehero.com/file/53277439/CC-Assignment2pdf/
A b B
b
D C
b
a, b
Example 2: a
We have the following ɛ-NFA for RE= (ab)*.
ɛ
1 ɛ 2 a ɛ b ɛ 6
3 4 5
ɛ
Transition Table:
States (ɛ-Closures) State (ɛ-Closures) after State (ɛ-Closures) after
reading 0 reading 1
1,2,6 = A (initial state) Ø=B 3,4 = C
Ø=B Ø=B Ø=B
3,4 = C 2,5,6 = D Ø=B
2,5,6 = D (final state) Ø=B 3,4 = C
We keep on building the Transition table until we get no new states. As in the table above, we have
considered all states (A, C, D) for input on the left side. Now we can make DFA using this Transition
table.
This study source was downloaded by 100000874451805 from CourseHero.com on 03-02-2024 08:00:39 GMT -06:00
https://www.coursehero.com/file/53277439/CC-Assignment2pdf/
A 0 B
0,1
1 1 0
C D
0
Example 3: 1
2 a 3
ɛ ɛ
0 ɛ ɛ a b
1 6 7 8 9
ɛ ɛ b
4 b 5
10
Transition Table:
1
States (ɛ-Closures) State (ɛ-Closures) after State (ɛ-Closures) after
reading 0 reading 1
0,1,2,4,7 = A (initial state) 3,6,7,1,2,4,8 = B 5,6,7,1,2,4 = C
3,6,7,1,2,4,8 = B 3,6,7,1,2,4,8 = B 5,6,7,1,2,4,9 = D
5,6,7,1,2,4 = C 3,6,7,1,2,4,8 = B 5,6,7,1,2,4 = C
5,6,7,1,2,4,9 = D 3,6,7,1,2,4,8 = B 5,6,7,1,2,4,10 = E
5,6,7,1,2,4,10 = E (final state) 3,6,7,1,2,4,8 = B 5,6,7,1,2,4 = C
This study source was downloaded by 100000874451805 from CourseHero.com on 03-02-2024 08:00:39 GMT -06:00
https://www.coursehero.com/file/53277439/CC-Assignment2pdf/
a
A a B
b a b a
a
C D
b
b b
E
Q3: Specify a pattern for white spaces using regular expressions and make
transition diagram to recognize it.
Solution:
RE= \s +\ t + \n + \r
0 \ 1 s 2 Single space
t 3 tab space
n 4 New line
r 5 Carriage Return
Q4: Specify a pattern for all Strings in which {1,2,3} exist in ascending
order and make transition diagram to recognize it.
This study source was downloaded by 100000874451805 from CourseHero.com on 03-02-2024 08:00:39 GMT -06:00
https://www.coursehero.com/file/53277439/CC-Assignment2pdf/
Solution:
RE= 1+ 2+ 3+
1 2 3
1 2 3
a
ɛ ɛ
c
ɛ
ɛ ɛ
ɛ b
d
ɛ
Q7: Convert the following NFA with -transitions into a DFA using the
subset construction.
This study source was downloaded by 100000874451805 from CourseHero.com on 03-02-2024 08:00:39 GMT -06:00
https://www.coursehero.com/file/53277439/CC-Assignment2pdf/
Solution:
Transition table for NFA:
Current State State after reading State after reading
0 1
q0 q0 q0,q1
q1 - q2
q3 q1 q1
q4 q3 q0,q3
But for DFA, for 1 input from current state transition happens for one state only. Here, in above NFA
for input 1 q0 is going to q0 and q1. So, we need to solve this issue.
Transition table for DFA:
Current State State after reading State after reading
0 1
q0 = S1 q0 = S1 {q0,q1} = S2 (one combined
state)
{q0,q1} = S2 q0 = S1 {q0,q1,q2} = S3
{q0,q1,q2} = S3 {q0,q1} = S2 {q0,q1,q2} = S3
Corresponding DFA:
0
S1 1 S2
0
0 1
S3
This study source was downloaded by 100000874451805 from CourseHero.com on 03-02-2024 08:00:39 GMT -06:00
https://www.coursehero.com/file/53277439/CC-Assignment2pdf/
Powered by TCPDF (www.tcpdf.org)