Cs2303-Theory of Computation
Cs2303-Theory of Computation
CS2303
THEORY OF COMPUTATION
UNIT-I AUTOMATA
PART-A(2-MARKS)
1 What is Computation? and Write short notes on TOC.
2 Define Automaton
3 Define Inductive and Deductive proof
4 Define hypothesis.
5 What is the principle of Mathematical Induction?
6 List any four ways of theorem proving.
7 What is structural Induction?
8 Write the central concepts of Automata Theory
9 Define Language and Give example.
10 Define transition diagram.
11 What is Finite Automata and explain the applications of Finite automata.
12 Define the languages described by NFA and DFA.
13 Give the DFA accepting the language over the alphabet 0,1 that have the set of
all strings beginning with 101.
14 Give the DFA accepting the language over the alphabet 0,1 that have the set of
all strings containing 1101 as a substring.
15 Give the DFA accepting the language over the alphabet 0,1 that have the set of
all strings ending in 00.
16 Give the DFA accepting the language over the alphabet 0,1 that have the set of
all strings with three consecutive 0’s.
17. Give the DFA accepting the language over the alphabet 0,1 that have the set of
all strings with 011 as a substring.
18 Give the DFA accepting the language over the alphabet 0,1 that have the set of
all strings whose 10th symbol from the right end is 1.
19 Construct a DFA for the following
a) All stings that contain exactly 4 zeros
b) All strings that don’t contain the substring 110.
20 Give the DFA accepting the language over the alphabet 0,1 that have the set of
all strings that either begins or end(or both) with 01.
21 Give the DFA accepting the language over the alphabet 0,1 that have the set of
all strings such that the no of zero’s is divisible by 5 and the no of 1’s is
divisible by 3.
22 Difference between DFA and NFA
23 Define NFA.
24 Define the language of NFA.
25. Is it true that the language accepted by any NFA is different from the regular
language? Justify your Answer.
26. Define ε-NFA.
27. Define ε closure.
28. Find the εclosure for each state from the following automata.
Part B
0 1
p {q,s} {q}
q {r} {q,r}
r {s} {p}
s - {p}
2. a)Show that the set L={an bn/n>=1} is not a regular. (6) b)Construct a DFA equivalent to the
0 1
p {p,q} P
q r R
r s -
s s S
3. a)Check whether the language L=(0n 1n /n>=1) is regular or not? Justify your answer.
b) Let L be a set accepted by a NFA then show that there exists aDFA that accepts L.
4.
5. a) Construct a NDFA accepting all string in {a,b}+ with either two consecutive
a’s or two consecutive b’s.
b) Give the DFA accepting the following language:set of all strings beginning with a 1 that
when interpretedas a binary integer is a multiple of 5.
(i) Set of Strings over alphabet {0,1,…….9} such that the final digit has
appeared before. (8)
(ii)Set of strings of 0’s and 1’s such that there are two 0’s separated by a number of
positions that is a multiple of 4.
7.a)Let L be a set accepted by an NFA.Then prove that there exists a deterministic finite
automaton that accepts L.Is the converse true? Justify your answer. (10)
8.a) Prove that a language L is accepted by some ε-NFA if and only if L is accepted by some
DFA. (8)
b) Consider the following ε-NFA.Compute the ε-closure of each state and find it’s equivalent DFA.
(8)
ε A b C
p {q} {p} Ф Ф
q {r} ф {q} Ф
*r Ф ф ф {r}
9.a) Prove that a language L is accepted by some DFA if L is accepted by some NFA.
p {p,q} {p}
q {r} {r}
r {s} ф
*s {s} {s}
10.a) Explain the construction of NFA with εtransition from any given regular
expression.
b) Let A=(Q,∑, δ, q0 ,{qf ) be a DFA and suppose that for all a in ∑wehave δ(q0, a)= δ(qf ,a). Show
that if x is a non empty string in L(A),then for all k>0,xk is also in L(A).
11.
states ε a b C
14.
15.
17.Prove that all Natural numbers of the form n3+2n are divisible by 3 using Prniciple of
Induction.
19.1+2+3+……….+n = n(n+1)/2
PART-A
PART-B
1.a)Construct an NFA equivalent to (0+1)*(00+11)
b)Obtain the regular expression that denotes the language accepted by the following DFA.
5.a)Obtain the regular expression denoting the language accepted by the following DFA (8)
b)Obtain the regular expression denoting the language accepted by the following DFA by
k
using the formula Rij
11.a) Find the regular expression for the set of all strings denoted by R213 from the
deterministic finite automata given below:
b)Verify whether the finite automata M1 and M2 given below are equivalent over {a,b}.
13.a)Find the regular expression corresponding to the finite automaton given below.
b)Find the regular expression for the set of all strings denoted by R223 from the
deterministic finite automata given below.
14.a) Find whether the languages {ww,w is in (1+0)*} and {1k | k=n2 , n>=1} are regular or
not.
b) Show that the regular languages are closed under intersectionand reversal.
15. If L = L(A) for some DFA A,then there is a regular expression R such that L=L(R).
16.Every language defined by a regular expression is also defined by a Finite automaton. (Or) Let r
be a regular expression is also defined by a finite automaton.
19. Find the regular expression for the set of all strings denoted by R2 13 from the deterministic finite
automata given below: (16)
(OR)
b) i) Show that the regular languages are closed under intersectionand reversal. (8)
ii) Show that the set L={On2/n is an integer,n>=1} is not regular. (8)
20.
21.
22.
23.
PART-A
1. Define CFG.2.Find L(G)where G=({S},{0,1},{S->0S1,S->ε},S).
2. Define derivation tree for a CFG(or)Define parse tree.
3. Construct the context-free grammar representing the set of palindromes over
(0+1)*
4. construct a context free Grammar for the given expression (a+b) (a+b+0+1) *
5. Consruct a CFG for the language L = { an / n is odd}
6. Construct the CFG for generating the language L={an bn /n>=1}.
7. Let G be the grammar S->aB/bA,A->a/aS/bAA,B->b/bS/aBB.for the string
aaabbabbba find the left most derivation.
8. Let G be the grammar S->aB/bA,A->a/aS/bAA,B->b/bS/aBB.obtain parse tree for the
string aaabbabbba.
9. For the grammar S->aCa,C->aCa/b.Find L(G).
10. Show that id+id*id can be generated by two distinct leftmost derivation in the
grammar E->E+E | E*E | (E) | id .
11. For the grammar S->A1B,A->0A | ε, B-> 0B | 1B| ε,give leftmost and rightmost
derivations for the string 00101.
12. Find the language generated by the CFG G=({S},{0,1},{S->0/1/ ε,
S->0S0/1S1},S).
13. obtain the derivation tree for the grammar G=({S,A},{a,b},P,S) where P
consist of S->aAS / a, A->SbA / SS / ba.
14.Consider the alphabet ∑={a,b,(,),+,*, ., ε} .Construct the context free grammar
that generates all strings in ∑* that are regular expression over the alphabet
{a,b}.
15 Write the CFG to generate the set {am bn cp | m + n=p and p>=1}.
16 Construct a derivation tree for the string 0011000 using the grammar
S->A0S |0 | SS , A-> S1A | 10.
17 Give an example for a context free grammar.
18 Let the production of the grammar be S-> 0B | 1A, A-> 0 | 0S | 1AA,
B-> 1|1S | 0BB.for the string 0110 find the right most derivation.
19 What is the disadvantages of unambiguous parse tree. Give an example.
20 Give an example of PDA.
21. Define the acceptance of a PDA by empty stack. Is it true that the language accepted
by a PDA by empty stack or by that of final state are different languages.
22. What is additional featurePDA has when compared with NFA? Is PDA superior over
NFA in the sense of language acceptance? Justify your answer.
23. Explain what actions take place in the PDA by the transitions (moves)
δ(q,a,Z)={(p1,γ1),(p2, γ2),…..(pm, γm)} and δ(q, ε,Z)= {(p1,γ1),(p2,
γ2),…..(pm,γm)}.
19. What are the different ways in which a PDA accepts the language? Define them. Is a true
that non deterministic PDA is more powerful than that of deterministic
PDA? Justify your answer.
20. Explain acceptance of PDA with empty stack.
21. Is it true that deterministic push down automata and non deterministic push
down automata are equivalent in the sense of language of acceptances? Justify your
answer.
22. Define instantaneous description of a PDA.
23. Give the formal definition of a PDA.
24. Define the languages generated by a PDA using final state of the PDA and
empty stack of that PDA.
25. Define the language generated by a PDA using the two methods of accepting a
language.
26. Define the language recognized by the PDA using empty stack.
27. For the Grammar G defined by the productions
S → A/ B
A → 0A/ɛ
B → 0B/ 1B/ɛ
Find the parse tree for the yields (i) 1001 (ii) 00101
28. Construct the Grammar with the productions
E → E+E
E→id Check whether the yield id + id + id is having the parse tree with root E or not.
29. What is ambiguous and un ambiguous Grammar?
30. Show that E→E+E/E*E/( E ) / id is ambiguous.
31. S→aS/ aSbS/ɛ is ambiguous and find the un ambiguous grammar.
32. Define the Instantaneous Descriptions ( ID )
PART-B
1. a) Let G be a CFG and let a=>w in G. Then show that there is a leftmost
derivation of w.
b) Let G=(V,T,P,S) be a Context free Grammar then prove that if S=> αthen there is a
derivation tree in G with yield α.
δ(q0,b,z0)={(q0,zz0)}
δ(q0,b,z)={(q0,zz)}
δ(q0,a,z)={(q1,z)}
δ(q1,b,z)={(q1, ε)}
δ(q1,a,z0)={(q0,z0)}
5. a)If L is Context free language then prove that there exists PDA M such that L=N(M).
b)Define deterministic Push Down Automata DPDA. Is it true that DPDA and PDA are
equivalent in the sense of language acceptance is concern? Justify Your answer.
b)Find the left most and right most derivation corresponding to the tree.
b) Prove that if L is N(M1) for some PDA M1 then L is L(M2 ) for some PDA M2.
15.
UNIT-IV PROPERTIES OF CONTEXTFREE LANGUAGES
PART-A
1. Define multitape Turing Machine.
2. Explain the Basic Turing Machine model and explain in one move. What are the
actions take place in TM?
3. Explain how a Turing Machine can be regarded as a computing device to compute
integer functions.
4. Describe the non deterministic Turing Machine model. Is it true the non deterministic
5. Turing Machine model’s are more powerful than the basic Turing Machines? (In the
sense of language Acceptance).
6. Explain the multi tape Turing Machine mode. Is it more power than the basic turing
machine? Justify your answer.
7. Using Pumping lemma Show that the language L={ an bn cn |n>=1} is not a CFL.
8. What is meant by a Turing Machine with two way infinite tape.
9. Define instantaneous description of a Turing Machine.
10. What is the class of language for which the TM has both accepting and rejecting
configuration? Can this be called a Context free Language?
11. The binary equivalent of a positive integer is stored in a tape. Write the
necessary transition to multiply that integer by 2.
12. What is the role of checking off symbols in a Turing Machine?
13. State Pumping lemma for Context free language.
14. Define a Turing Machine.
15. Mention any two problems which can only be solved by TM.
16. State Pumping lemma and its advantages.
17. What are useless symbols in a grammar.
PART‐B
1. Find a grammar in Chomsky Normal form equivalent to S‐>aAD;A‐>aB/bAB; B‐>b, D‐>d.
2. Convert to Greibach Normal Form the grammar G=({A1,A2, A3},{a,b},P,A1 ) where P
consists of the following. A1 ‐>A2 A3, A2 ‐>A3 A1 /b,A3 ‐>A1 A2 /a.
3. Construct given CFG into GNF where v={S,A},T={0,1} and P is S AA/0 , ASS/1
4. Convert the grammar S‐>AB, A‐>BS/b, B‐>SA/a into Greibach NormalForm.
5. Construct a equivalent grammar G in CNF for the grammar G1 where G1
=({S,A,B},{a,b},{S‐>bA/aB,A‐>bAA/aS/a, B‐>aBB/bS/b}, S)
6. Obtain the Chomsky Normal Form equivalent to the grammars S aAbB , A aA/a,
BbB/b
7. Begin with the grammar
S‐>0A0/1B1/BBA‐>CB‐>S/AC‐>S/ ε and simplify using the safe order Eliminate ε‐
Productions Eliminate unit production Eliminate useless symbols Put the (resultant)
grammar in Chomsky Normal Form
8 Let G=(V,T,P,S) be a CFG. Show that if S=α, then there is a derivation tree in a
grammar G with yield α.
9 Let G be the grammar S‐>aS/aSbS/ ε. Prove that L(G)={x/each prefix of x has 10
atleast as many a's as b's}
11 Explain the Construction of an equivalent grammar in CNF for the grammar
G=({S,A,B}{a,b},P,S) where P={S a/AAB , A ab/aB/€ ,Baba/€.
12 Find a Context free grammar with no useless symbol equivalent to S‐>AB/CA, B‐
>BC/ABA‐>a, C‐>aB/b.
13 Show that any CFL without ε can be generated by an equivalent grammar in Chomsky
Normal Form.
14 Convert the following CFG to CNF S‐>ASA|aB A‐>B|S B‐>b| ε
15 Convert into Greibach Normal Form for Sa/AB , Aa/BC ,Bb ,Cb 16
Is L={an b n c n /n>=1} a context free language? Justify Your answer.
17 Prove that for every context free language L without ε there exists an equivalent
grammar in Greibach Normal Form.
18 State and Prove pumping lemma for Context free languages.
19 show that language {ai bj ci dj/i>=1,and j>=1} is not context‐free.
20 Design a Turing Machine M to implement the function “multiplication” using
the subroutine ‘copy’.
21 Explain how a Turing Machine with the multiple tracks of the tape can be used to
determine the given number is prime or not.
22 Design a Turing Machine to compute f(m+n)=m+n, V m,n>=0 and simulate their
action on the input 0100.
23 Define Turing machine for computing f(m,n)=m‐n ( proper subtraction).
24 Explain how the multiple tracks in a Turing Machine can be used for testing given
positive integer is a prime or not.
25 Explain in detail:” The Turing Machine as a Computer of integer functions”. 26
Design a Turing Machine to accept the language L={0 n 1n/n>=1}
27 What is the role of checking off symbols in a Turing Machine?
28 Construct a Turing Machine that recognizes the language
{w cw/w € {a,b} + }
29 Prove that the language L is recognized by a Turing Machine with a two way
infinite tape if and only if it is recognized by a Turing Machine with a one way
infinite tape.
30 Design a TM to recognize each of the following languages. {ww R | w € (0+1) *}
31 Design a Turing Machine M that decides A={0k /n>0 and k=2n } the language consisting
of all strings of 0’s whose length is a power of 2.
32 Demonstrate the working of your TM with an example.
33 Show that the language{0n 1n 2n/n>=1}is not context free.
34 Show that the context free languages are closed under union operation but not under
intersection.
35 Design a TM with no more than three states that accepts the language.
a(a+b) *.Assume €={a,b}
36. Design a TM to implement the function f(x)= x+1.
37. Design a TM to accept the set of all strings {0,1} with 010 as substring.
38. Design a TM to accept the language LE={a n b n c n|n > 1 }
UNIT-V UNDECIDABILITY
PART-A
1. When a recursively enumerable language is said to be recursive.
2. Is it true that the language accepted by a non deterministic Turing Machine is
different from recursively enumerable language?
3. When we say a problem is decidable? Give an example of undecidable problem?
4. Give two properties of recursively enumerable sets which are undecidable.
5. Is it true that complement of a recursive language is recursive? Justify your answer.
6. When a language is said to be recursive or recursively enumerable?
7. When a language is said to be recursive? Is it true that every regular set is not
8. recursive?
9. When a problem is said to be decidable or undecidable? Give an example of an
undecidable.
10. What do you mean by universal Turing Machine?
11. When a problem is said to be undecidable? Give an example of an decidable problem.
12. Show that the union of recursive language is recursive.
13. Show that the union of two recursively enumerable languages is recursively
enumerable.
14. What is undecidability problem?
15. Show that the following problem is undecidable.“Given two CFG’s G1 and G2, is
L(G1)∩L(G2)=Φ?”.
16. Define recursively enumerable language.
17. Give an example for a non recursively enumerable language.
18. Differentiate between recursive and recursively enumerable languages.
19. Mention any two undecidability properties for recursively enumerable language.
20. Define Diagonal languages.
21. Give an example for an undecidable problem.
22. Define MPCP.
PART‐B
1. Show that union of recursive languages is recursive.
2. Define the language Ld and show that Ld is not recursively enumerable language.
3. Explain the Halting problem. Is it decidable or undecidable problem
4. Define Universal language Lu.Show that Lu is recursively enumerable but not recursive.
5. Obtain the code for the TM M=({q1,q2,q3},{0,1}, {0,1,B}, δ,q1,B,{q2}) With the moves
δ(q1,1)=(q3,0,R) δ(q3,0)=(q1,1,R) δ(q3,1)=(q2,0,R) δ(q3,B)=(q3,1,L) δ(q3,B)=(q3,1,L)
6. Show that Ln is recursively enumerable.
7. Define Ld and show that L d is not recursively enumerable.
8. Whether the problem of determining given recursively enumerable language is
empty or not? Is decidable? Justify your answer.
9. Define the language L u. Check whether L u is recursively enumerable? or L u is
recursive? Justify your answer.
10. Show that the language L d is neither recursive nor recursively enumerable.
11. Describe how a Turing Machine can be encoded with 0 and 1 and give an example.
12. Show that any non trivial property J of the recursively enumerable languages is
undecidable.
13. Show that if L and L are recursively enumerable then L and L recursive.
14. Define the universal language and show that it is recursively enumerable but not
recursive.
15. Prove that the universal language Lu is recursively enumerable.
16. State and Prove Rice’s Theorem for recursive index sets.
17. Show that the following language is not decidable. L={<M>| M is a TM that accepts the
string aaab}.
18. Discuss the properties of Recursive and Recursive enumerable languages.
19. Define Post correspondence problem with an example.
20. Prove that the function f(n)=2n does not grow at a polynomial rate, in other words, it
does not satisfy f(n)=O(np ) for any finite exponent p.
21. Every non trivial property of the RE language is undecidable
22. Show that if a language L and its complement L are both recursively enumerable then L
is recursive.
23. What are the features of a Universal Turing Machine?
24. Show that “If a language L and its compliment L are both recursively enumerable,then
both languages are recursive”.
25. Show that halting problem of Turing Machine is undecidable.
26. Does PCP with two lists x=(b,b ab3,ba) and y=(b3 ,ba , a)have a solution?. Show that the
characteristic function of the set of all even numbers is recursive.
27. Let Σ={0,1}.Let A and B be the lists of three strings each,defined as List A List B
| W i| = 1, 10111 ,10 |X I |= 111 ,10 ,0 Find the instance of PCP.
28. Show that it is undecidable for arbitrary CFG’s G1 and G2 whether L(G1)∩L(G2)Is a CFL.
29. Show that “finding whether the given CFG is ambiguous or not” is undecidable by
reduction technique.
30. Find whether the following languages are recursive or recursively enumerable.
a. Union of two recursive languages.
b. Union of two recursively enumerable languages.
c. L if L and complement of L are recursively enumerable. (iv)Lu (4)
31. Consider the Turing Machine M and w=01, where M=({q1,q2,q3},{0,1},
{0,1,B},δ,q1,B,{q3}) and δis given by Reduce the above problem to Post’s
correspondence Problem and find whether that PCP has a solution or not.
32. Explain the Post’s Correspondence Problem with an example
33. Define Lne and show that L ne is recursively enumerable.
34. Explain in detail NP, NP hard, NP Complete problems giving suitable examples.
35. Convert the TM
M={q1,q2,q3},{0,1},{0,1,,B}, δ,q1,B,{q3}} where δ is given by
qi δ ( q i 0) δ ( q i, 1) δ ( q i, B)
q1 (q 2 ,1, R) (q 2 ,0, L) (q 2 ,1, L)
q2 (q 3 ,0,L) (q 1 ,0, R) (q 2 ,0, R)
q3 -- -- --