0% found this document useful (0 votes)
29 views2 pages

Assignment 3 4

M

Uploaded by

hub9004
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)
29 views2 pages

Assignment 3 4

M

Uploaded by

hub9004
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/ 2

CSO322 - Theory of Computation

Department of Mathematical Sciences


Indian Institute of Technology (BHU) Varanasi
Assignment - 2 - Context-free Grammars
1. Construct a context-free grammar for the regular expression/language
(a) (0 + 1)∗ 0(1)∗
(b) (011 + 1)∗ (01)∗
(c) abba(baa)n aab(aaba)n |n ≥ 0
2. Construct the string 0100110 from the grammar with production rules {S → 0S|1AA, A →
0|1A|0B, B → 1|0BB} by using (a) left most derivation , (b) right most derivation.
3. Consider the grammar G = {V, Σ, S, P } where V = {S, A}, Σ = {a, b}, P = {S → AA, A →
AAA|a|bA|Ab}
(a) Which string of L(G) can be produced by derivations of four or less steps.
(b) Give at least 4 distinct derivations for the string babbab.
(c) For any m, n, p > 0 describe a derivation in G of the string bm abn abp .
4. Consider the grammar G = {V, Σ, S, P } where V = {S, A, B}, Σ = {a, b}, P = {S → aB|bA, A →
a|aS|BAA, B → b|bS|ABB}
(a) Show that ababba ∈ L(G).
(b) Prove that L(G) is the set of strings in {a, b} that have equal number of occurrences of a
and b.
5. Consider the grammar G = {V, Σ, S, P } where V = {S}, Σ = {a, b}, P = {S → aSb|aSa|bSa|
bSb|}. Show that L(G) is regular.
6. Find the parse tree for generating the string 11001010 from the given grammar over {0, 1} with
production rules {S → 1B|0A, A → 1|1S|0AA, B → 0|0S|1BB}.
7. Find the derivation tree and the derivation of the string aabbaa from {S → a|aAS, A → SS|
SbA|ba}.
8. Let G be a context-free grammar with productions S → S + S|S ∗ S|(S)|a and let G1 be the
grammar with productions S1 → S1 + T |T, T → T ∗ F |F, F → (S1 )|a.
Show that L(G1 ) = L(G) and G1 is unambiguous.
9. Remove -production from the grammars with production rules:
(a) {S → aA, A → b|} over Σ = {a, b}.
(b) {S → ABaC, A → BC, B → b|, C → D|, D → d} over Σ = {a, b, d}.
10. Remove unit productions from the grammar for the language over Σ = {a, b}:
(a) {S → AB, A → a, B → C, C → D, D → b}
(b) {S → AB, A → E, B → C, C → D, D → b, E → a}
11. Convert the following into CNF for the language over Σ = {a, b}:
(a) {S → bA|aB, A → bAA|aS|a, B → aBB|bS|a}
(b) {S → ABa, A → aab, B → AC, C → a}
(c) {S → abAB, A → bAB|, B → BAa|}

1
Assignment - 3 - Push Down Automata

1. Construct a PDA to accept the language L = {an bn cm dm |n, m ≥ 1}, (i) by empty stack, and (ii)
by final state.

2. Construct a PDA to accept the language L = {an b2n |n ≥ 1}, (i) by empty stack, and (ii) by final
state.

3. Construct a PDA and DPDA for the language L = {an bn+m cm |n ≥ 0, m ≥ 1}.

4. Construct a PDA for the CFG:

(a) {S → aAB|bBA, A → bS|a, B → aS|b}. Show the derivation for the string abbaaabbbbab.
(b) {S → aB, B → bA|b, A → aB}. Find the ID for the string abab.

5. Construct a CFG for the PDA M = (Q, Σ, Γ, q0 , Z0 , δ, {q2 }) where Q = {q0 , q1 , q2 }, Σ = {a, b},
Γ = {a, b, Z0 } and δ is given by:=
δ(q0 , a, Z0 ) = {(q1 , aZ0 )}
δ(q0 , b, Z0 ) = {(q1 , bZ0 )}
δ(q1 , a, a) = {(q1 , a), (q2 , a)}
δ(q1 , b, a) = {(q1 , a)}
δ(q1 , a, b) = {(q1 , b)}
δ(q1 , b, b) = {(q1 , b), (q2 , b)}.

6. Construct a CFG for the language of the palindromes whose PDA accepts by empty stack.

7. For the PDA of language of palindromes draw the computation tree showing all possible sequence
of moves for the three input strings aabab, aba and abaaba.

8. Show that every regular language can be accepted by a deterministic PDA with only two states
in which there are no -transitions and no symbols are ever removed from the stack.

9. Show that if L is accepted by a PDA in which no symbols are ever removed from the stack, then
L is regular.

10. Suppose M1 and M2 are PDA’s accepting the languages L1 and L2 . Describe a procedure for
constructing a PDA accepting the following languages.

(a) L1 ∪ L2 ,
(b) L1 .L2 , and
(c) L∗1 .

Precisely describe how the stack of the machine works. No relationship is assumed between the
stack alphabets of M1 and M2 .

11. Show by using Pumping Lemma, the following languages are not CFL.

(a) L = {ai bj ck |i < j < k}.


(b) L = {an b2n an |n ≥ 0}.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy