SlideShare ist ein Scribd-Unternehmen logo
1 von 4
Downloaden Sie, um offline zu lesen
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.

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
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
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
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
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGSIVASHANKAR N
 

Kürzlich hochgeladen (20)

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
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
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
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
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 

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.