0% found this document useful (0 votes)
24 views3 pages

Final Term Paper Spring2018

Uploaded by

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

Final Term Paper Spring2018

Uploaded by

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

Name: ____________________________ Seat No.

_________

Institute of Business Administration, Karachi


Faculty of Computer Science
CSE309-Theory of Automata
Spring Semester Examination, 2018

Date: 12-5-2018 Duration: 3 hrs.


Teacher: Ms. Naveen Z. Quazilbash Max Marks: 30

Instructions:
 Attempt all questions.

Q1: (Marks: 2+3=5)


a) Let A be the language consisting of all strings over {0,1} containing a 1 in the third
position from the end (e.g. 000100 is in A but 0011 is not). Construct an NFA for the
language A.

b) Construct an equivalent DFA for the following NFA N:

Q2: Write regular expressions for the following languages defined over = {0, 1}:
(Marks: 1x4=4)

a) {w | w contains a single 1}
b) {w | w has at least one 1}
c) {w | every 0 in w is followed by at least one 1}
d) {w | the length of w is a multiple of three}

Q3: Convert the regular expression (a U b)*aba to a -NFA. (Marks: 2)

Q4: Obtain the language generated by each of the following production rules. Also write down
their RE (Regular Expression). (Marks: 1x2=2)

a) S aS
S ε

b) S aS
S bS
S a
Page 1 of 3
Name: ____________________________ Seat No. _________

Q5: Begin with the grammar: (Marks: 1x4=4)


S ASB | ε
A aAS | a
B SbS | A |bb

a) Are there any useless symbols? Eliminate them if so.


b) Eliminate ε -productions.
c) Eliminate unit productions
d) Put the grammar into Chomsky normal form.

Q6: Here is a context-free grammar G = ({S, A, B}, {0, 1}, P, S), where P is the set of
productions: (Marks: 1x3=3)

S 0A | 1B| ε
A  1S | 0AA
B  0S | 1BB

Intuitively, A generates strings with one more 1 than 0, B generates strings with one more
0 than 1, and S generates the strings with equal numbers of 0's and 1's.

a) Give a leftmost derivation of the string 0011.


b) Give a rightmost derivation of the string 001011.
c) Draw a parse tree for the string 1001.

Q7: Show the ID’s of the following Turing Machine that accepts {0n1n | n≥1}, If the input tape
contains: (Marks: 2x3=6)
a) 00
b) 000111
c) 00111

Symbol
State 0 1 X Y B
q0 (q1 , X, R) - - (q3 , Y, R) -
q1 (q1 , 0, R) (q2 , Y, L) - (q1 ,Y, R) -
q2 (q2 , 0, L) - (q0 , X, R) (q2 , Y, L) -
q3 - - - (q3 , Y, R) (q4 , B, R)
q4 - - - - -

Page 2 of 3
Name: ____________________________ Seat No. _________

Q8: (Marks: 2x2=4)


a) For the given transition functions of a PDA M

M = ({q1, q2, q3, q4}, {0, 1}, {$, 0, 1}, d, q1, {q4})

where d is defined as follows:


d(q1, e, e) à { (q2, $) }
d(q2, 0, e) à { (q2, 0) }
d(q2, 1, 0) à { (q3, e) }
d(q3, 1, 0) à { (q3, e) }
d(q3, e, $) à { (q4, e) }
(...and all others are undefined)

Starting from the initial ID (q1, ω , e), show all reachable ID’s when the input ω is 000111.

b) Given that the PDA P= ({q, p}, {0, 1}, {Z0, X}, δ, q, Z0, {p}) has the following transition
function:

1. δ (q0, 0, Z0)={(q0, 0Z0)}


2. δ (q0, 1, Z0)={(q0, 1Z0)}
3. δ (q0, 0, 0)={(q0, 00)}
4. δ (q0, 0, 1)={(q0, 01)}
5. δ (q0, 1, 0)={(q0, 10)}
6. δ (q0, 1, 1)={(q0, 11)}
7. δ (q0, ε, Z0)={(q1, Z0)}
8. δ (q0, ε, 0)={(q1, 0)}
9. δ (q0, ε, 1)={(q1, 1)}
10. δ (q1, 0, 0)={(q1, ε)}
11. δ (q1, 1, 1)={(q1, ε)}
12. δ (q1, ε, Z0)={(q2, Z0)}

Starting from the initial ID (q0, ω, Z0), show all the reachable ID’s when the input ω is 1111.

Good Luck 

Page 3 of 3

You might also like