0% found this document useful (0 votes)
12 views

2023 Midsem Evaluation Scheme

Uploaded by

vineetjha0909
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

2023 Midsem Evaluation Scheme

Uploaded by

vineetjha0909
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Semester: 4th

Sub & Code: OS & CS - 2009


Branch (s): CSE, IT, CSSE, CSCE

AUTUMN MID SEMESTER EXAMINATION-2023


School of Computer Engineering
Kalinga Institute of Industrial Technology, deemed to be University
Automata Theory and Formal Languages
[CS21003]
Time: 1 1/2 Hours Full Mark: 40

Answer Any four Questions including Question No. 1 which is compulsory.


The figures in the margin indicate full marks. Candidates are required to give their answers in their own words as
far as practicable and all parts of a question should be answered at one place only.

1. Answer all the questions. [2x5]


a) Design a NFA that accepts strings over {a,b} in which 4th symbol from right hand side is ‘b’.
Ans:

b) Consider the following DFAs. Find the language accepted by the union of the languages
accepted by the respective DFAs where Σ= {0,1}
DFA1 DFA2

Ans: L(DFA1) = Φ , L(DFA2) = {ε}


L(DFA1) ∪ L(DFA2) = Φ ∪ {ε} = {ε} Final Answer

c) Prove or disprove the following statement: If L1 and L2 are not regular languages,
then L1 ∪L2 is not regular.
Ans: It is a disprove statement.
Consider L1 = {ambn | m ≥ n} and L2 = {ambn | m < n}.
Both L1 and L2 are non-regular languages, but their union L1 ∪ L2 is the language {ambn | m ≥ n} ∪ {ambn
| m < n} = a*b*, which is a regular language.

d) From the identities of regular expression;


Prove that: (a+abb*)+(a+abb*)(b+ab*)(b+ab*)*=ab*(b+ab*)*
Ans:(a+abb*)+(a+abb*)(b+ab*)(b+ab*)* = (a+abb*)(ε+(b+ab*)(b+ab*)*)
= (a+abb*)(b+ab*)*
= a(ε+bb*)(b+ab*)*
= ab*(b+ab*)*
Proved.
Semester: 4th
Sub & Code: OS & CS - 2009
Branch (s): CSE, IT, CSSE, CSCE
e) Consider the following table: Find out the extended transition function: δ*(1, aba)

δ a b ε
→1 Φ Φ {2}
2 {3} Φ {5}
3 Φ {4} Φ
4 {4} Φ {1}
5 Φ {6,7} {3}
6 {5} Φ Φ
*7 Φ 4 {1}
Ans: δ*(1, aba) = ECLOSE(δ(ECLOSE(δ(ECLOSE(δ(ECLOSE(1),a)),b)),a))
= ECLOSE(δ(ECLOSE(δ(ECLOSE(δ({1,2,3,5},a)),b)),a))
= ECLOSE(δ(ECLOSE(δ(ECLOSE({3}),b)),a))
= ECLOSE(δ(ECLOSE(δ({3},b)),a))
= ECLOSE(δ(ECLOSE({4}),a))
= ECLOSE(δ({1,2,3,4,5},a))
= ECLOSE({3,4})
= {1,2,3,4,5}Final Answer
2) a) Design a minimal DFA that accepts strings defined over Σ= {0,1} such that it’s decimal equivalent is
not divisible by 6. [ 5 Marks ]
Ans:
Semester: 4th
Sub & Code: OS & CS - 2009
Branch (s): CSE, IT, CSSE, CSCE
b) Write regular expression for the following languages over {0,1} [ 5 Marks ]
i. L={w| w does not end with 101}
Ans: The DFA for above language is shown below (Note1: -Not required for students to make this DFA
in answer, I am only providing for reference)

The RE for above language is RE1 = 0*(1 + 11*(0 + 0(0 + (10)* + 11)))
Note2: - If we apply state elimination on above DFA then 16 more complex answers can be there out
of which one is RE2 = (11*0(0+1((0+11*0)1)*(0+11*0)0))*(ε+11*(ε+0+01((0+11*0)1)*(0+11*0)))
Note3: - Any simplification of above expression can also be the answer.
Note4: - Some other simple answers can also be possible as given below:-
RE3 = (0+1)* - (0+1)*(���)+
RE4 = (0+1)* - (0+1)*(101)(101)*

ii. Set of all strings neither containing 01 nor 10.

Ans: There can be several possible answers of this question as below:-


RE1 = (��)+ + (��)+
RE2 = ��(��)∗ + ��(��)∗
RE3 = (0+1)* - ((��)+ + (��)+ )
RE4 = (0+1)* - (��(��)∗ + ��(��)∗ )
RE5 = 0* + 1*

iii. L={uwu : 1≤ | u | ≤2}

Ans: RE = 0(0 + 1)*0 + 1(0 + 1)*1 + 00(0 + 1)*00 + 01(0 + 1)*01 + 10(0 + 1)*10 + 11(0 + 1)*11 Final
Answer

iv. L={ w: |w| mod 4=0 and |w| mod 2 ≠ 0}

Ans: RE = ∅

v. alternate sequence of 0’s and 1’s

Ans: RE = (ε + 1)(01)* + (ε + 0)(10)* or RE = (01)* + (10)* + 1(01)* +0 (10)* Final Answer


Semester: 4th
Sub & Code: OS & CS - 2009
Branch (s): CSE, IT, CSSE, CSCE
3) a) Find the regular expression for the following DFA using State Elimination Method.
[ 5 Marks ]

Ans: This problem can be solved in six ways, First way is as below:
Step1: Eliminate State q3 as it is unreachable from initial state. After eliminating q3, the DFA will become:

Step2: There should not be any incoming edge at initial state so we have to make a new initial state qi by
inserting an ε-transition from qi to q0. After inserting new initial state qi, the DFA will become:

Step3: There should not be any outgoing edge at final state so we have to make a new final state qf by
inserting an ε-transition from q0 to qf. After inserting new final state qf, the DFA will become:

Step4: Now we eliminate state q1. After eliminating state q1, the DFA will become:

Step5: Now we eliminate state q2. After eliminating state q2, the DFA will become:

Step6: Now we eliminate state q0. After eliminating state q0, the DFA will become:

Step7: The final Regular Expression will be the cost of eliminating state q0 and qf thus the final RE is:
RE = (00*1 + 1(0 + 10*1))* or RE = (00*1 + 10 + 110*1)*
Semester: 4th
Sub & Code: OS & CS - 2009
Branch (s): CSE, IT, CSSE, CSCE
Second way of solving the above problem is as below:
Step1: Eliminate State q3 as it is unreachable from initial state. After eliminating q3, the DFA will become:

Step2: There should not be any incoming edge at initial state so we have to make a new initial state qi by
inserting an ε-transition from qi to q0. After inserting new initial state qi, the DFA will become:

Step3: There should not be any outgoing edge at final state so we have to make a new final state qf by
inserting an ε-transition from q0 to qf. After inserting new final state qf, the DFA will become:

Step4: Now we eliminate state q2. After eliminating state q2, the DFA will become:

Step5: Now we eliminate state q1. After eliminating state q1, the DFA will become:

Step6: Now we eliminate state q0. After eliminating state q0, the DFA will become:

Step7: The final Regular Expression will be the cost of eliminating state q0 and qf thus the final RE is:
RE = (10+(0+11)0*1)* or RE = (10+00*1+110*1)*
Similarly, other four versions can be calculated.
Thus, total 6 answers of this question are valid. The answers are given below :- Final Answers
Answer1 :- RE = (00*1 + 1(0 + 10*1))* or RE = (00*1 + 10 + 110*1)*
Answer2 :- RE = (10+(0+11)0*1)* or RE = (10+00*1+110*1)*
Answer3 :- RE = (00*1)* + (00*1)*1((0+10*1)(00*1)*1)*(0+10*1)(00*1)*
Answer4 :- RE = (10)* + (10)*(0+11)(0+1(10)*(0+11))*1(10)*
Answer5 :- RE = ε+1(01)*0 + (0+1(01)*(1+00))(0+10+11(01)*(1+00))*(1+11(01)*0)
Answer6 :- RE = ε+0(0+10)*1 + (1+0(0+10)*11)(01+(1+00)(0+10)*11)*(0+(1+00)(0+10)*1)
Semester: 4th
Sub & Code: OS & CS - 2009
Branch (s): CSE, IT, CSSE, CSCE
3)b) Convert the following NFA with ε-transition to DFA. [ 5 Marks ]

Ans: The transition table of above ε-NFA is given below:


δ ε a b
{q0} {q0,q1,q3} {q0} {q2}
{q1} {q1,q3} {q2} ∅
{q2} {q2,q3} ∅ {q1,q3}
{q3} {q3} ∅ {q3}

The starting state of DFA of above ε-NFA = ECLOSE(q0) = {q0,q1,q3}


The next states of DFA is calculated in the table given below : - Final Answer

δ a b
{q0,q1,q3} ECLOSE({q0,q2}) = {q0,q1,q2,q3} ECLOSE({q2,q3}) = {q2,q3}
{q0,q1,q2,q3} ECLOSE({q0,q2}) = {q0,q1,q2,q3} ECLOSE({q1,q2,q3}) = {q1,q2,q3}
{q2,q3} ECLOSE(∅ ) = ∅ ECLOSE({q1,q3}) = {q1,q3}
{q1,q2,q3} ECLOSE({q2}) = {q2,q3} ECLOSE({q1,q3}) = {q1,q3}
{q1,q3} ECLOSE({q2}) = {q2,q3} ECLOSE({q3}) = {q3}
{q3} ECLOSE(∅ ) = ∅ ECLOSE({q3}) = {q3}
∅ ECLOSE(∅ ) = ∅ ECLOSE(∅ ) = ∅

The final transition table of DFA is given below : - Final Answer


δ a b
{q0,q1,q3} {q0,q1,q2,q3} {q2,q3}
{q0,q1,q2,q3} {q0,q1,q2,q3} {q1,q2,q3}
{q2,q3} ∅ {q1,q3}
{q1,q2,q3} {q2,q3} {q1,q3}
{q1,q3} {q2,q3} {q3}
{q3} ∅ {q3}
∅ ∅ ∅
Semester: 4th
Sub & Code: OS & CS - 2009
Branch (s): CSE, IT, CSSE, CSCE
The transition graph of above DFA is given below (Note :- ∅ state is represented as qd): Final Answer

4) a) Design a NFA for the given regular expression: (ab+ba)*(ab*)*bb [ 5 Marks ]

Ans: First, we will draw the NFA for basic strings i.e. NFA of ab, NFA of ba, NFA of bb as below:

Fig. NFA of ab Fig. NFA of ba Fig. NFA of bb

Now, we will draw the NFA of ab + ba as below:

Now, we will draw the NFA of ab* as below:

Now, we will draw the NFA of (ab + ba)* as below:

Now, we will draw the NFA of (ab*)* as below:


Semester: 4th
Sub & Code: OS & CS - 2009
Branch (s): CSE, IT, CSSE, CSCE
Now, we will draw the final NFA of (ab+ba)*(ab*)*bb as below: Final Answer

4)b) Minimize the DFA given below and draw the minimized DFA. [ 5 Marks ]

Ans:
Step1: Eliminate State q6 and q7 as these states are unreachable from initial state.
Step 2: After eliminating states q6 and q7, we have drawn below the transition table for all pair of states.

states a b
q0 q3 q1
q1 q4 q1
q2 q0 q2
q3 q5 q2
q4 q3 q1
q5 q5 q5

Step 3: All the states are divided in two partitions − final states and non-final states and are denoted by P0.
All the states in a partition are 0th equivalent. Take a counter k and initialize it with 0.
a
P0 = {(q0,q3,q4,q5), (q1,q2)}
b
Semester: 4th
Sub & Code: OS & CS - 2009
Branch (s): CSE, IT, CSSE, CSCE
Step 4: Since state q5 behaves differently for b transition, we will separate the state q5, and the new partition
will become:
a
P2 = {(q0,q3,q4),(q5), (q1,q2)}
b

Step 5: Since state q3 behaves differently for a transition, we will separate the state q3, and the new partition
will become:
a
P3 = {(q0,q4),(q3)(q5), (q1,q2)}
b

Step 6: Since no state behaves differently for any transition, so the new partition will become:
P4 = {(q0,q4),(q3)(q5), (q1,q2)}

Step 7: Since P3 = P4,we will stop the further partition generation and we combine the final equivalent sets
and make them the new states of the reduced DFA as below: Final Answer

states a b
(q0,q4) q3 (q1,q2)
(q1,q2) (q0,q4) (q1,q2)
q3 q5 (q1,q2)
q5 q5 q5

The transition diagram for above transition table will be:- Final Answer
Semester: 4th
Sub & Code: OS & CS - 2009
Branch (s): CSE, IT, CSSE, CSCE
5) a) State pumping lemma for regular languages. Prove that the language L={anbn+1 : n>=1}
is not regular using pumping lemma. [ 5 Marks]
Ans:
Pumping lemma : - Let L be a regular language. Then there exists a constant n (which depends on L) such
that for every string w in L such that |w| ≥ n, we can break w into three strings, w = xyz, such that:

1. y ≠ ϵ.
2. |xy| ≤ n.
3. For all k ≥ 0, the string xykz is also in L.

Proof for the language L={anbn+1 : n>=1} is not regular using pumping lemma : -
Suppose it was regular. Then there exists a constant n satisfying the conditions of the pumping lemma.
Let w = a2b3 by taking n = 2. Here |w| = 5 ≥ n.
Using the pumping lemma we can break w = xyz so that y ≠ ϵ and |xy| ≤ 2.
Suppose x = a, y = a and z = b3.
Then we know by the pumping lemma that xy3z is in L. Thus a4b3 ∈ L.
This is not possible because 3 ≠ 4+1. Hence the language is not regular. Proved.

Note:- There can be many combination of values for above proof so multiple answers of this proof is
valid.

b) Prove that family of regular languages are closed under difference and intersection. [ 5 Marks ]
Ans:
Proof of close under intersection : -

Proof of close under difference : -

Note:- The name of regular languages can be different for each student.

You might also like