You are on page 1of 2

Academic Session 2018-2019

MC304 Theory of Computation

Assignment-III

1. Find context-free grammars for the following languages (with n ≥ 0, m ≥ 0).


(a) L = {an bm : n 6= m1}
(b) L = {an bm : 2n ≤ m ≤ 3n}
(c) L ={w ∈ {a, b}∗ : na (w) = 2nb (w) + 1}
2. Reduce the following grammars to Chomsky Normal Form.
(a) S → 1A|0B, A → 1AA|0S|0, B → 0BB|1S|1
(b) S → a|b|cSS
3. Reduce the following grammars to Greibach Normal Form.
(a) S → SS|0S1|01
(b) S → AB, A → BSB|BB|b, B → aAb|a
4. Show that the following grammars are ambiguous.
(a) S → a|abSb|aAb, A → bS|aAAb
(b) S → aB|ab, A → aAB|a|, B → ABb|b
5. Use Pumping lemma to show that following are not context free languages:
2
(a) {an |n ≥ 1}
(b) {am bm cn |m ≤ n ≤ 2m}
6. Construct pda’s that accept the following languages on Σ = {a, b, c}.

(a) {w : na (w) = 2nb (w)}


(b) {wcwR : w ∈ {a, b}∗ }
(c) {an bn+m cm : n ≥ 0, m ≥ 1}

7. If the initial ID of the pda A is (q0 , aacaa, Z0 ).what is the ID after processing of aacaa?If the input string
is (i)abcba, (ii)abcb, (iii)acba, (iv)abac, (v)abab,will A process the entire string?If,so what will be the final
ID?
A = ({q0 , q1 , qf }, {a, b, c}, {a, b, Z0 }, δ, q0 , Z0 , F )
where δ is defined as:

δ(q0 , a, Z0 ) = {(q0 , aZ0 )} δ(q0 , b, Z0 ) = {(q0 , bZ0 )}


δ(q0 , a, a) = {(q0 , aa)} δ(q0 , b, b) = {(q0 , bb)}
δ(q0 , a, b) = {(q0 , ab)} δ(q0 , b, a) = {(q0 , ba)}
δ(q0 , c, a) = {(q1 , a)} δ(q0 , c, b) = {(q1 , b)}
δ(q0 , c, Z0 ) = {(q1 , Z0 )} δ(q1 , ∧, Z0 ) = {(qf , Z0 )}
δ(q1 , a, a) = δ(q1 , b, b) = {(q1 , ∧)}

1
Present State Tape Symbol
b 0 1
→ q1 1Lq2 0Rq1
q2 bRq3 0Lq2 1Lq2
q3 bRq4 bRq5
q4 0Rq5 0Rq4 1Rq4
q5 0Lq2

8. Draw the transition diagram for Turing machine given below:

9. Construct a Context-free grammar G accepting N (M ) for the pda M given below:

A = ({q0 , q1 , qf }, {a, b}, {a, Z0 }, δ, q0 , Z0 , qf )

where δ is defined as:

δ(q0 , a, Z0 ) = {(q0 , aZ0 )} δ(q1 , b, a) = {(q1 , ∧)}


δ(q0 , a, a) = {(q0 , aa)} δ(q1 , ∧, Z0 ) = {(q1 , ∧)}
δ(q0 , b, a) = {(q1 , ∧)}

10. Construct the computation sequence for strings 1213, 2133, 312 for the Turing machine given below:
Present State Input Tape Symbol
1 2 3 b
→ q1 bRq2 bRq1
q2 1Rq2 bRq3 bRq2
q3 2Rq3 bRq4 bRq3
q4 3Lq5 bLq7
q5 1Lq6 2Lq5 bLq5
q6 1Lq6 bRq1
q7

You might also like