SlideShare a Scribd company logo
1 of 4
Download to read offline
Department of Mathematics and Statistics, I.I.T. Kanpur
MTH401 Theory of Computation - Problem Set 2
(1) The following grammar generates the language consisting of all strings of even
length.
S −→ AS |
A −→ aa | ab | ba | bb.
Give the leftmost and rightmost derivations for the following strings:
(a) aabbba
(b) baabab
(c) aaabbb
(2) Construct non-deterministic pushdown machine to accept the following languages.
Please comment and explain your machines.
(a) {1n
0n
: n > 0}.
(b) {0n
12n
: n ≥ 0}.
(c) {1n
0n
: n > 0} ∪ {0n
12n
: n ≥ 0}.
(d) L[(0 + 1)∗
] − {ww : w ∈ {0, 1}∗
} (this is the complement of ww).
(3) Construct deterministic pushdown machine to accept the following languages. Ex-
plain why it works.
(a) {10n
1n
: n > 0} ∪ {110n
12n
: n > 0}.
(b) Binary strings that contain an equal number of 0’s and 1’s.
(c) Binary strings with twice as many ones as zeros.
(d) Binary strings that start and end with the same symbol, and have the same
number of zeros as ones.
(4) Construct Context Free Grammars that generate following languages. Explain your
grammars.
(a) {w ∈ {0, 1}∗
: w starts and ends with the same symbol}.
(b) {w ∈ {0, 1}∗
: the length of w is odd}.
(c) {w ∈ {0, 1}∗
: the length of w is odd and its and middle symbol is a 0}.
(d) {0n
1n
: n > 0} ∪ {0n
12n
: n > 0}.
(e) {0i
1j
2k
: i = j or j = k}.
(f) Binary strings with twice as many ones as zeros.
1
2
(5) Explain why the grammar below is ambiguous.
S −→ 0A | 1B
A −→ 0AA | 1S | 1
B −→ 1BB | 0S | 0
(6) Put the following grammar into Chomsky normal form. Show all work.
S −→ A | AB0 | A1A
A −→ A0 |
B −→ B1 | BC
C −→ CB | CA | 1B
(7) Convert the following grammar to an equivalent one with no unit productions and
no useless symbols. Show that the original grammar had NO useless symbols. What
useless symbols are there after getting rid of unit productions?
S −→ A | CB
A −→ C | D
B −→ 1B | 1
C −→ 0C | 0
D −→ 2D | 2
(8) Show that the following languages are deterministic context free.
(a) {am
bn
: m = n}.
(b) {wcwR
: w ∈ {a, b}∗
}.
(9) Show that, if G is a CFG in Chomsky normal form, then for any string w in L(G)
of length n ≥ 1, exactly 2n − 1 steps are required for any derivation of w.
(10) Let G be a CFG in Chomsky normal form that contains b variables. Show that,
if G generates some string using a derivation with at least 2b
steps, then L(G) is
infinite.
(11) L = {a3k+1
b5k−2
: k ≥ 1}.
(a) Write a CFG G with L(G) = L.
(b) Design a pushdown machine M with L(M) = L.
(c) Is the machine you designed in (b) a deterministic pushdown machine?
3
(12) Write a pushdown machine that accepts exactly what the grammar below generates.
S −→ AB | BC
A −→ BA | 0
B −→ CC | 1
C −→ AB | 0
(13) Let Σ = {a, b, c} and L = {αcαR
cα : α ∈ {a, b}∗
}.
(a) Show that L is not context free.
(b) Write L as an intersection of two context free languages (over Σ).
(14) Determine and prove whether each of the following languages is Context Free or
not.
(a) {1k
0i
1i
0j
1j
0k
: i, j, k > 0}.
(b) {0i
1i
0j
1j
: i, j > 0}.
(c) The complement of {(0n
1n
)m
: m, n > 0}.
(15) Describe algorithms to decide the problems below.
(a) Does a given Deterministic Pushdown Automaton generate (0+1)*?
(b) Given a CFG and a string z in its language, does the string have 2 distinct
derivation trees? (Note: your algorithm does not test whether or not the
grammar is ambiguous! For that you would have to test every string.)
(16) Explain why the intersection of a regular language and a CFL must be a CFL (i.e.
CFL’s are closed under intersection with regular sets). You should illustrate your
argument by constructing the machine that generates L intersected with R, where
L = {0n
1n
: n > 0} and R = L[(0 + 1)∗
110(0 + 1)∗
].
(17) Show that the intersection of a regular language and a CFL is not necessarily regular
(though it must be a CFL - see the previous problem).
(18) Show that
(a) the language L = {ww : w ∈ {0, 1}∗
} is not a context free language.
(b) {0, 1}∗
 L is a context free language.
(19) Let L be a context free language and n be the pumping lemma constant. Prove
that if there is a string w ∈ L such that |w| ≥ n, then there also exists a string
˜w ∈ L with | ˜w| ≤ 2n − 1.
4
(20) Prove that there is no algorithm to test the ambiguity of a given context free
language. If needed, you may assume that the Post Correspondence Problem is
undecidable.

More Related Content

What's hot

Write declarations for each of the following variables: a. amounts is a...
Write declarations for each of the following variables:       a. amounts is a...Write declarations for each of the following variables:       a. amounts is a...
Write declarations for each of the following variables: a. amounts is a...licservernoida
 
Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammarlavishka_anuj
 
0015.register allocation-graph-coloring
0015.register allocation-graph-coloring0015.register allocation-graph-coloring
0015.register allocation-graph-coloringsean chen
 
Instructions: This Hex/Decimal Converter program should prompt the user to en...
Instructions: This Hex/Decimal Converter program should prompt the user to en...Instructions: This Hex/Decimal Converter program should prompt the user to en...
Instructions: This Hex/Decimal Converter program should prompt the user to en...hwbloom116
 
Automatic variational inference with latent categorical variables
Automatic variational inference with latent categorical variablesAutomatic variational inference with latent categorical variables
Automatic variational inference with latent categorical variablesTomasz Kusmierczyk
 
Solve the problem showing all steps. Thoroughly explain how and why you perfo...
Solve the problem showing all steps. Thoroughly explain how and why you perfo...Solve the problem showing all steps. Thoroughly explain how and why you perfo...
Solve the problem showing all steps. Thoroughly explain how and why you perfo...hwbloom60
 
Variational inference using implicit distributions
Variational inference using implicit distributionsVariational inference using implicit distributions
Variational inference using implicit distributionsTomasz Kusmierczyk
 
Theory of Automata and formal languages Unit 5
Theory of Automata and formal languages Unit 5Theory of Automata and formal languages Unit 5
Theory of Automata and formal languages Unit 5Abhimanyu Mishra
 
Polish Notation In Data Structure
Polish Notation In Data StructurePolish Notation In Data Structure
Polish Notation In Data StructureMeghaj Mallick
 
Ec2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.orgEc2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.organnaunivedu
 
Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3Srimatre K
 
Assembly language-lab9
Assembly language-lab9Assembly language-lab9
Assembly language-lab9AjEcuacion
 
Register Allocation
Register AllocationRegister Allocation
Register AllocationEelco Visser
 
Church Turing Thesis
Church Turing ThesisChurch Turing Thesis
Church Turing ThesisHemant Sharma
 
3.3 Logarithmic Functions
3.3 Logarithmic Functions3.3 Logarithmic Functions
3.3 Logarithmic FunctionsVictoria Ryburn
 
Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016sergejsvolkovs10
 

What's hot (19)

Write declarations for each of the following variables: a. amounts is a...
Write declarations for each of the following variables:       a. amounts is a...Write declarations for each of the following variables:       a. amounts is a...
Write declarations for each of the following variables: a. amounts is a...
 
Flat
FlatFlat
Flat
 
Assignment2
Assignment2Assignment2
Assignment2
 
Simplifiaction of grammar
Simplifiaction of grammarSimplifiaction of grammar
Simplifiaction of grammar
 
0015.register allocation-graph-coloring
0015.register allocation-graph-coloring0015.register allocation-graph-coloring
0015.register allocation-graph-coloring
 
Instructions: This Hex/Decimal Converter program should prompt the user to en...
Instructions: This Hex/Decimal Converter program should prompt the user to en...Instructions: This Hex/Decimal Converter program should prompt the user to en...
Instructions: This Hex/Decimal Converter program should prompt the user to en...
 
Automatic variational inference with latent categorical variables
Automatic variational inference with latent categorical variablesAutomatic variational inference with latent categorical variables
Automatic variational inference with latent categorical variables
 
Solve the problem showing all steps. Thoroughly explain how and why you perfo...
Solve the problem showing all steps. Thoroughly explain how and why you perfo...Solve the problem showing all steps. Thoroughly explain how and why you perfo...
Solve the problem showing all steps. Thoroughly explain how and why you perfo...
 
Variational inference using implicit distributions
Variational inference using implicit distributionsVariational inference using implicit distributions
Variational inference using implicit distributions
 
Theory of Automata and formal languages Unit 5
Theory of Automata and formal languages Unit 5Theory of Automata and formal languages Unit 5
Theory of Automata and formal languages Unit 5
 
Polish Notation In Data Structure
Polish Notation In Data StructurePolish Notation In Data Structure
Polish Notation In Data Structure
 
Ec2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.orgEc2203 digital electronics questions anna university by www.annaunivedu.org
Ec2203 digital electronics questions anna university by www.annaunivedu.org
 
Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3Formal Languages and Automata Theory unit 3
Formal Languages and Automata Theory unit 3
 
Turing machine
Turing machineTuring machine
Turing machine
 
Assembly language-lab9
Assembly language-lab9Assembly language-lab9
Assembly language-lab9
 
Register Allocation
Register AllocationRegister Allocation
Register Allocation
 
Church Turing Thesis
Church Turing ThesisChurch Turing Thesis
Church Turing Thesis
 
3.3 Logarithmic Functions
3.3 Logarithmic Functions3.3 Logarithmic Functions
3.3 Logarithmic Functions
 
Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016
 

Similar to Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur

Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016appasami
 
V cse cs6503 model qb1 1
V  cse cs6503  model qb1 1V  cse cs6503  model qb1 1
V cse cs6503 model qb1 1Ezhumalai p
 
Cs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersCs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersappasami
 
Hw2 2017-spring
Hw2 2017-springHw2 2017-spring
Hw2 2017-spring奕安 陳
 
TOC Solutions-Adi.pdf
TOC Solutions-Adi.pdfTOC Solutions-Adi.pdf
TOC Solutions-Adi.pdfAdiseshaK
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfAdiseshaK
 
Problem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurProblem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurVivekananda Samiti
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfdawod yimer
 
ALC-Prac-10A.pdfMAT2ALC Practice Class 10A Turing Machines.docx
ALC-Prac-10A.pdfMAT2ALC Practice Class 10A Turing Machines.docxALC-Prac-10A.pdfMAT2ALC Practice Class 10A Turing Machines.docx
ALC-Prac-10A.pdfMAT2ALC Practice Class 10A Turing Machines.docxnettletondevon
 
9 a05407 formal_languages_automata_theor_yfr_2029
9 a05407 formal_languages_automata_theor_yfr_20299 a05407 formal_languages_automata_theor_yfr_2029
9 a05407 formal_languages_automata_theor_yfr_2029Rajesh Yaramadi
 
Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007 Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007 Rohit Garg
 
Theory of computing
Theory of computingTheory of computing
Theory of computingRanjan Kumar
 
CS2303 Theory of computation April may 2015
CS2303 Theory of computation April may  2015CS2303 Theory of computation April may  2015
CS2303 Theory of computation April may 2015appasami
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxRaviAr5
 

Similar to Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur (20)

Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016Cs2303 theory of computation may june 2016
Cs2303 theory of computation may june 2016
 
V cse cs6503 model qb1 1
V  cse cs6503  model qb1 1V  cse cs6503  model qb1 1
V cse cs6503 model qb1 1
 
Cs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papersCs2303 theory of computation all anna University question papers
Cs2303 theory of computation all anna University question papers
 
Question bank toafl
Question bank toaflQuestion bank toafl
Question bank toafl
 
toc_model_qp2-.pdf
toc_model_qp2-.pdftoc_model_qp2-.pdf
toc_model_qp2-.pdf
 
Hw2 2017-spring
Hw2 2017-springHw2 2017-spring
Hw2 2017-spring
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdf
 
TOC Solutions-Adi.pdf
TOC Solutions-Adi.pdfTOC Solutions-Adi.pdf
TOC Solutions-Adi.pdf
 
TOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdfTOC_Solutions-Adi.pdf
TOC_Solutions-Adi.pdf
 
Problem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurProblem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Problem set3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 
TOC question bank.pdf
TOC question bank.pdfTOC question bank.pdf
TOC question bank.pdf
 
Chapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdfChapter 3 REGULAR EXPRESSION.pdf
Chapter 3 REGULAR EXPRESSION.pdf
 
ALC-Prac-10A.pdfMAT2ALC Practice Class 10A Turing Machines.docx
ALC-Prac-10A.pdfMAT2ALC Practice Class 10A Turing Machines.docxALC-Prac-10A.pdfMAT2ALC Practice Class 10A Turing Machines.docx
ALC-Prac-10A.pdfMAT2ALC Practice Class 10A Turing Machines.docx
 
9 a05407 formal_languages_automata_theor_yfr_2029
9 a05407 formal_languages_automata_theor_yfr_20299 a05407 formal_languages_automata_theor_yfr_2029
9 a05407 formal_languages_automata_theor_yfr_2029
 
Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007 Gate Computer Science Solved Paper 2007
Gate Computer Science Solved Paper 2007
 
Tests
TestsTests
Tests
 
Theory of computing
Theory of computingTheory of computing
Theory of computing
 
Cs 73
Cs 73Cs 73
Cs 73
 
CS2303 Theory of computation April may 2015
CS2303 Theory of computation April may  2015CS2303 Theory of computation April may  2015
CS2303 Theory of computation April may 2015
 
Mod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptxMod 2_RegularExpressions.pptx
Mod 2_RegularExpressions.pptx
 

More from Vivekananda Samiti

End semester examination | MTH 653A, IITK Integral Equation
End semester examination | MTH 653A, IITK Integral Equation End semester examination | MTH 653A, IITK Integral Equation
End semester examination | MTH 653A, IITK Integral Equation Vivekananda Samiti
 
Mth 653 a end sem paper | Integral Equation
Mth 653 a end sem paper | Integral Equation Mth 653 a end sem paper | Integral Equation
Mth 653 a end sem paper | Integral Equation Vivekananda Samiti
 
Regression project report | Regression analysis | MTH 426 IITK
Regression project report | Regression analysis | MTH 426 IITK Regression project report | Regression analysis | MTH 426 IITK
Regression project report | Regression analysis | MTH 426 IITK Vivekananda Samiti
 
Project co prediction Regression analysis | MTH 426 IITK
Project co prediction Regression analysis | MTH 426 IITK Project co prediction Regression analysis | MTH 426 IITK
Project co prediction Regression analysis | MTH 426 IITK Vivekananda Samiti
 
Indian eduaction system group 13 | MTH 423A IITK
Indian eduaction system group 13 | MTH 423A IITKIndian eduaction system group 13 | MTH 423A IITK
Indian eduaction system group 13 | MTH 423A IITKVivekananda Samiti
 
Final presentation | MTH426A IITK
Final presentation | MTH426A IITKFinal presentation | MTH426A IITK
Final presentation | MTH426A IITKVivekananda Samiti
 
Mth 416A, Regression Analysis - 2016 midsem, endsem and quizes
Mth 416A, Regression Analysis - 2016   midsem, endsem and quizesMth 416A, Regression Analysis - 2016   midsem, endsem and quizes
Mth 416A, Regression Analysis - 2016 midsem, endsem and quizesVivekananda Samiti
 
Mth 416A end sem paper 2017, IITK
Mth 416A end sem paper 2017, IITK Mth 416A end sem paper 2017, IITK
Mth 416A end sem paper 2017, IITK Vivekananda Samiti
 
Mth 401 IITK theory of computation 2016
Mth 401 IITK theory of computation 2016Mth 401 IITK theory of computation 2016
Mth 401 IITK theory of computation 2016Vivekananda Samiti
 
Mth 412 IITK end sem paper 2016
Mth 412 IITK end sem paper 2016Mth 412 IITK end sem paper 2016
Mth 412 IITK end sem paper 2016Vivekananda Samiti
 
Phy 301 a end sem paper | Energy, IIT Kanpur
Phy 301 a end sem paper | Energy, IIT KanpurPhy 301 a end sem paper | Energy, IIT Kanpur
Phy 301 a end sem paper | Energy, IIT KanpurVivekananda Samiti
 
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurEnd semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurVivekananda Samiti
 
Fluidendsem | Mth 523 Fluid Dynamics | B V Rathish Kumar | IIT Kanpur
Fluidendsem | Mth 523 Fluid Dynamics | B V Rathish Kumar | IIT KanpurFluidendsem | Mth 523 Fluid Dynamics | B V Rathish Kumar | IIT Kanpur
Fluidendsem | Mth 523 Fluid Dynamics | B V Rathish Kumar | IIT KanpurVivekananda Samiti
 
Quiz3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Quiz3 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurQuiz3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Quiz3 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurVivekananda Samiti
 
Mid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Mid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurMid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Mid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurVivekananda Samiti
 
Quiz2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Quiz2 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurQuiz2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Quiz2 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurVivekananda Samiti
 

More from Vivekananda Samiti (20)

End semester examination | MTH 653A, IITK Integral Equation
End semester examination | MTH 653A, IITK Integral Equation End semester examination | MTH 653A, IITK Integral Equation
End semester examination | MTH 653A, IITK Integral Equation
 
Mth 653 a end sem paper | Integral Equation
Mth 653 a end sem paper | Integral Equation Mth 653 a end sem paper | Integral Equation
Mth 653 a end sem paper | Integral Equation
 
Regression project report | Regression analysis | MTH 426 IITK
Regression project report | Regression analysis | MTH 426 IITK Regression project report | Regression analysis | MTH 426 IITK
Regression project report | Regression analysis | MTH 426 IITK
 
Project co prediction Regression analysis | MTH 426 IITK
Project co prediction Regression analysis | MTH 426 IITK Project co prediction Regression analysis | MTH 426 IITK
Project co prediction Regression analysis | MTH 426 IITK
 
Mth426 group13 final_report
Mth426 group13 final_reportMth426 group13 final_report
Mth426 group13 final_report
 
Indian eduaction system group 13 | MTH 423A IITK
Indian eduaction system group 13 | MTH 423A IITKIndian eduaction system group 13 | MTH 423A IITK
Indian eduaction system group 13 | MTH 423A IITK
 
Final presentation | MTH426A IITK
Final presentation | MTH426A IITKFinal presentation | MTH426A IITK
Final presentation | MTH426A IITK
 
Mth 416A, Regression Analysis - 2016 midsem, endsem and quizes
Mth 416A, Regression Analysis - 2016   midsem, endsem and quizesMth 416A, Regression Analysis - 2016   midsem, endsem and quizes
Mth 416A, Regression Analysis - 2016 midsem, endsem and quizes
 
Mth 416A end sem paper 2017, IITK
Mth 416A end sem paper 2017, IITK Mth 416A end sem paper 2017, IITK
Mth 416A end sem paper 2017, IITK
 
Mth 401 IITK theory of computation 2016
Mth 401 IITK theory of computation 2016Mth 401 IITK theory of computation 2016
Mth 401 IITK theory of computation 2016
 
Mth 412 IITK end sem paper 2016
Mth 412 IITK end sem paper 2016Mth 412 IITK end sem paper 2016
Mth 412 IITK end sem paper 2016
 
Phy 301 a end sem paper | Energy, IIT Kanpur
Phy 301 a end sem paper | Energy, IIT KanpurPhy 301 a end sem paper | Energy, IIT Kanpur
Phy 301 a end sem paper | Energy, IIT Kanpur
 
Phy 301 a Presentation
Phy 301 a Presentation Phy 301 a Presentation
Phy 301 a Presentation
 
Phy 301 a | Project Report
Phy 301 a | Project ReportPhy 301 a | Project Report
Phy 301 a | Project Report
 
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurEnd semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
End semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 
Mth 523 end sem paper
Mth 523 end sem paper Mth 523 end sem paper
Mth 523 end sem paper
 
Fluidendsem | Mth 523 Fluid Dynamics | B V Rathish Kumar | IIT Kanpur
Fluidendsem | Mth 523 Fluid Dynamics | B V Rathish Kumar | IIT KanpurFluidendsem | Mth 523 Fluid Dynamics | B V Rathish Kumar | IIT Kanpur
Fluidendsem | Mth 523 Fluid Dynamics | B V Rathish Kumar | IIT Kanpur
 
Quiz3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Quiz3 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurQuiz3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Quiz3 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 
Mid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Mid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurMid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Mid semexam | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 
Quiz2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Quiz2 | Theory of Computation | Akash Anand | MTH 401A | IIT KanpurQuiz2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
Quiz2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur
 

Recently uploaded

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 

Recently uploaded (20)

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 

Problem set2 | Theory of Computation | Akash Anand | MTH 401A | IIT Kanpur

  • 1. Department of Mathematics and Statistics, I.I.T. Kanpur MTH401 Theory of Computation - Problem Set 2 (1) The following grammar generates the language consisting of all strings of even length. S −→ AS | A −→ aa | ab | ba | bb. Give the leftmost and rightmost derivations for the following strings: (a) aabbba (b) baabab (c) aaabbb (2) Construct non-deterministic pushdown machine to accept the following languages. Please comment and explain your machines. (a) {1n 0n : n > 0}. (b) {0n 12n : n ≥ 0}. (c) {1n 0n : n > 0} ∪ {0n 12n : n ≥ 0}. (d) L[(0 + 1)∗ ] − {ww : w ∈ {0, 1}∗ } (this is the complement of ww). (3) Construct deterministic pushdown machine to accept the following languages. Ex- plain why it works. (a) {10n 1n : n > 0} ∪ {110n 12n : n > 0}. (b) Binary strings that contain an equal number of 0’s and 1’s. (c) Binary strings with twice as many ones as zeros. (d) Binary strings that start and end with the same symbol, and have the same number of zeros as ones. (4) Construct Context Free Grammars that generate following languages. Explain your grammars. (a) {w ∈ {0, 1}∗ : w starts and ends with the same symbol}. (b) {w ∈ {0, 1}∗ : the length of w is odd}. (c) {w ∈ {0, 1}∗ : the length of w is odd and its and middle symbol is a 0}. (d) {0n 1n : n > 0} ∪ {0n 12n : n > 0}. (e) {0i 1j 2k : i = j or j = k}. (f) Binary strings with twice as many ones as zeros. 1
  • 2. 2 (5) Explain why the grammar below is ambiguous. S −→ 0A | 1B A −→ 0AA | 1S | 1 B −→ 1BB | 0S | 0 (6) Put the following grammar into Chomsky normal form. Show all work. S −→ A | AB0 | A1A A −→ A0 | B −→ B1 | BC C −→ CB | CA | 1B (7) Convert the following grammar to an equivalent one with no unit productions and no useless symbols. Show that the original grammar had NO useless symbols. What useless symbols are there after getting rid of unit productions? S −→ A | CB A −→ C | D B −→ 1B | 1 C −→ 0C | 0 D −→ 2D | 2 (8) Show that the following languages are deterministic context free. (a) {am bn : m = n}. (b) {wcwR : w ∈ {a, b}∗ }. (9) Show that, if G is a CFG in Chomsky normal form, then for any string w in L(G) of length n ≥ 1, exactly 2n − 1 steps are required for any derivation of w. (10) Let G be a CFG in Chomsky normal form that contains b variables. Show that, if G generates some string using a derivation with at least 2b steps, then L(G) is infinite. (11) L = {a3k+1 b5k−2 : k ≥ 1}. (a) Write a CFG G with L(G) = L. (b) Design a pushdown machine M with L(M) = L. (c) Is the machine you designed in (b) a deterministic pushdown machine?
  • 3. 3 (12) Write a pushdown machine that accepts exactly what the grammar below generates. S −→ AB | BC A −→ BA | 0 B −→ CC | 1 C −→ AB | 0 (13) Let Σ = {a, b, c} and L = {αcαR cα : α ∈ {a, b}∗ }. (a) Show that L is not context free. (b) Write L as an intersection of two context free languages (over Σ). (14) Determine and prove whether each of the following languages is Context Free or not. (a) {1k 0i 1i 0j 1j 0k : i, j, k > 0}. (b) {0i 1i 0j 1j : i, j > 0}. (c) The complement of {(0n 1n )m : m, n > 0}. (15) Describe algorithms to decide the problems below. (a) Does a given Deterministic Pushdown Automaton generate (0+1)*? (b) Given a CFG and a string z in its language, does the string have 2 distinct derivation trees? (Note: your algorithm does not test whether or not the grammar is ambiguous! For that you would have to test every string.) (16) Explain why the intersection of a regular language and a CFL must be a CFL (i.e. CFL’s are closed under intersection with regular sets). You should illustrate your argument by constructing the machine that generates L intersected with R, where L = {0n 1n : n > 0} and R = L[(0 + 1)∗ 110(0 + 1)∗ ]. (17) Show that the intersection of a regular language and a CFL is not necessarily regular (though it must be a CFL - see the previous problem). (18) Show that (a) the language L = {ww : w ∈ {0, 1}∗ } is not a context free language. (b) {0, 1}∗ L is a context free language. (19) Let L be a context free language and n be the pumping lemma constant. Prove that if there is a string w ∈ L such that |w| ≥ n, then there also exists a string ˜w ∈ L with | ˜w| ≤ 2n − 1.
  • 4. 4 (20) Prove that there is no algorithm to test the ambiguity of a given context free language. If needed, you may assume that the Post Correspondence Problem is undecidable.