Document

B.E./B.Tech DEGREE EXAMINATION, NOVEMBER/DECEMBER 2007
Fifth Semester
Computer Science and Engineering
CS1303 – Theory of computation
(Regulation 2004)
PART A – (10 X 2=20 marks)
1. List any four ways of theorem proving

Proof by mathematical induction

Proofs about sets

Proof by contradiction

Proofs by counterexample
2. Show that the complement of a regular language is also regular
Let L = L(A) for some DFA A = (Q ,
the DFA (Q ,
,
,
, q0, F ). Then L = L(B), where B is
, q0, Q - F ). That is, B is exactly like A, but the accepting states of A
have become nonaccepting states of B, and vice versa. Then w is in L(B) if and only if
( q0, w) is in Q – F, which occurs if and only if w is not in L(A).
Notice that it is important for the above proof that
( q0, w) is always some state;
i.e., there are no missing transitions in A. If there were, then certain strings might lead
neither to an accepting nor nonaccepting state of A, and those strings would be missing
from both L(A) and L(B). Fortunately, we have defined a DFA to have a transition on
every symbol of
from every state, so each string leads either to a state in F or a state in
Q – F.
3. What is meant by equivalent states in DFA?
We say that states p and q are equivalent if:

For all strings w,
( p, w) is an accepting state if and only if
( q, w) is an
accepting state.
4. State pumping lemma and its advantage
The pumping lemma for regular languages describes an essential property of all
regular languages. Informally, it says that all sufficiently long words in a regular
language may be pumped - that is, have a middle section of the word repeated an
1
arbitrary number of times - to produce a new word which also lies within the same
language.
Let L be a regular language. Then there exists an integer n ≥ 1 depending only on
L such that every string w in L of length at least n (n is called the "pumping length") can
be written as w = xyz (i.e., w can be divided into three substrings), satisfying the
following conditions:
1. |y| ≥ 1
2. |xy| ≤ n
3. for all i ≥ 0, xyiz is also in L
5. Consider the alphabet Σ={a,b,(,),+,*,.,Є}.Construct a context free grammar that
generates all strings in Σ* that are regular expressions over the alphabet {a,b}
E Є
Ea
Eb
EE*E
EE.E
E  (E)
EE+E
6. Find whether the language {ambmcm,m,≥0} is context free or not
Refer Page No : 186
7. Define the language recognized by the push down automata using empty stack
For each PDA P = (Q,
,
,
, q0, Z0, F ), we also define
N(P) = { w | (q0, w, Z0) ├* ( q, є, є ) }
for any state q. That is, N (P) is the set of inputs w that P can consume and at the
same time empty its stack.
8. What is meant by multi tape Turing machine?
A multi-tape Turing machine consists of a finite control with k-tape heads and ktapes; each tape is infinite in both directions. On a single move depending on the state of
finite control and symbol scanned by each of tape heads, the machine can change state
print a new symbol on each cells scanned by tape head, move each of its tape head
independently one cell to the left or right or remain stationary.
9. What are the useless symbols in a grammar?
These are the variables in CFG which does not derive any terminal or
not reachable from the start symbols.
2
10. Define Diagonal language
Diagonalization language Ld consists of all those strings w such that the TM
represented by w does not accept the input w.
PART B – (5 X 16 = 80 marks)
11. (a) Convert the regular expression “a(a+b)* a “ into Є-NFA and find the minimal state
DFA
(16)
Refer Page No: 115
(OR)
(b) (i) Draw transition diagram for recognizing the set of all operators in C language
(10)
Refer Page No: 53
(ii) Explain the extended transition function for NFA, DFA and Є-NFA
(6)
Refer Page No: 72, 63, and 90
12. (a) (i) Find the regular expression for the set of all strings denoted by R 223 form the
deterministic finite automata given below
start
1
1
(10)
1
2
3
0
Refer Page No: 106
(ii) Show that the language (0p,p is prime} is not regular.
(6)
Refer Page No: 140
(OR)
(b) (i) Find whether the languages {ww,w is in (1+0)*} and {1k|k=n2,n≥1} are regular
or not
(8)
Refer Page No: 140
(ii) Show that the regular languages are closed under intersection and reversal
(8)
Refer Page No: 145, 151
13. (a) (i) Prove that if L=N(PN) for some PDA PN=(Q, Σ,Г,δN,q0,Z0),then there is a PDA
PF such that L=L(PF).
(8)
Refer Page No: 245
3
(ii) Construct a PDA for the language {anb2n|n≥0}
(8)
Refer Page No: 237
(OR)
(b) (i) Show that the grammar S
a|Sa|bSS|SSb|SbS is ambiguous.
(8)
Refer Page No: 219
(ii) Construct PDA for the grammar:
S
B
aB|bA
b|bS|aBB
A
(8)
a|aS|bAA
Refer Page No: 255
14. (a) (i)Simplify the following grammar and find its equivalent in CNF
S
AB|CA
B
BC|AB
A
a
C
aB|b
(8)
Refer Page No: 280
(ii) Find the GNF equivalent of the grammar
S
AA | 0,A
SS|1.
(8)
Refer Page No: 285
(OR)
(b) (i) Design a Turing Machine M for f(x,y)=x * y where x, y are stored in the tape
in the form 0x10y1.
(12)
Refer Page No: 343
(ii) Show that context free languages are closed under union operation but not
under intersection
(4)
Refer Page No: 295
15. (a) Explain the post’s correspondence problem with an example
(16)
Refer Page No: 406
(OR)
(b) Find the languages obtained from the following operations:
(i) Union of two recursive languages
(6)
(ii) Union of two recursively enumerable languages
(6)
(iii) L if L and complement of L are recursively enumerable
(4)
Refer Page No: 382
4
B.E./B.Tech DEGREE EXAMINATION, NOVEMBER/DECEMBER 2006
Fifth Semester
Computer Science and Engineering
CS1303 – Theory of computation
(Regulation 2004)
PART A – (10 X 2=20 marks)
1. Construct a finite automata for the language {0n|n mod 3=2,n≥0}.
Refer Page No: 65
2. Let R be any set of regular languages. Is URi regular? Prove it
Refer Page No: 145
3. Consider the alphabet Σ={a,b,(,),+,*,.,Є}.Construct a context free grammar that
generates all strings in Σ* that are regular expressions over the alphabet {a,b}
E Є
Ea
Eb
EE*E
EE.E
E  (E)
EE+E
4. Write a CFG to generate the set {ambncp | m+n = p and p≥1}
Refer Page No: 185
5. Can you say the language generated by a CFG in CNF is finite or infinite? If so,how?If
not, why?
Refer Page No: 280
6. Define the languages generated by a PDA using final state of the PDA and empty stack
of that PDA
For each PDA P = (Q,
,
,
, q0, Z0, F ), we also define
N(P) = { w | (q0, w, Z0) ├* ( q, є, є ) }
for any state q. That is, N (P) is the set of inputs w that P can consume and
at the same time empty its stack.
Refer Page No: 251
7. What is the class of language for which the TM has both accepting and rejecting
configuration? Can this be called a context free language?
Refer Page No: 359
5
8. The binary equivalent of a positive integer is stored in a tape. Write the necessary
transitions to multiply that integer by 2
Refer Page No: 340
9. Show that the following problem is undecidable Given two CFGs G1 and G2, is
L(G1)∩L(G2 ) = Ф?”
Refer Page No: 387
10. Define Ld
Diagonalization language Ld consists of all those strings w such that the TM
represented by w does not accept the input w.
PART B – (5 X 16 = 80 marks)
11. (a) (i) Prove that a language L is accepted by some Є-NFA if and only if L is accepted
by some DFA
(8)
Refer Page No: 93
(ii) Consider the following Є-NFA. Compute the Є-closure of each state and find its
equivalent DFA
(8)
P
q
*r
Є
{q}
{r}
Ф
A
{p}
Ф
Ф
b
Ф
{q}
Ф
c
Ф
Ф
{r}
Refer Page No: 90
(OR)
(b) (i) Prove that a language L is accepted by some DFA iff L is accepted by some
NFA
(8)
Refer Page No: 78
(ii) Convert the following NFA to its equivalent DFA
0
1
p
{p,q} {p}
q
{r}
{r}
r
{s}
Ф
*s
{s}
{s}
Refer Page No: 74
6
(8)
12. (a) (i) Explain the construction of NFA with Є transition form any given regular
expression
(8)
Refer Page No: 115
(ii) Find the regular expression for the set of all strings denoted by R 213 form the
deterministic finite automata given below:
(8)
0
1
start
1
3
2
0,1
0
Refer Page No: 105
(OR)
(b) Find whether the following languages are regular or not
(i) L={w Є{a,b}|w=wR}
(4)
(ii) L={0n1m2n+m,n,m≥1}
(4)
(iii)L={1k|k=n2,n≥1}
(4)
(iv) L1/L2={x|for some y Є L2,xy Є L1} , where L1 and L2 are any two languages
and L1/L2 is the quotient of L1and L2.
(4)
Refer Page No: 140
13. (a) (i) Prove that if L=N(PN) for some PDA PN ==(Q, Σ,Г,δN,q0,Z0),then there is a PDA
PF such that L=L(PF).
(8)
Refer Page No: 245
(ii) Construct a PDA for {anbmc2(m+n) | n,m≥0}
(8)
Refer Page No: 237
(OR)
(b) (i) Show that the grammar S
aSbS|bSaS| Є
is ambiguous and what is the
language generated by this grammar?
(6)
Refer Page No: 219
(ii) Write a grammar to recognize all prefix expressions involving all binary
arithmetic operators. Construct parse tree for the sentence “-*+abc/de” using your
grammar.
(6)
Refer Page No: 185
7
(iii) Suppose G is a CFG and w, of length l, is in L(G). How long is a derivation of
w in G if G is in CNF and if G is in GNF?
(4)
Refer Page No: 280
14. (a) (i) Show that every CFL without Є can be generated by a CFG in CNF.
(4)
Refer Page No: 284
(ii) Simplify the following grammar and find its equivalent in CNF
S
bA|aB
A
bAA | aS |a
B
aBB | bS |b
(8)
Refer Page No: 280
(iii) Find the GNF equivalent of the grammar
S
AA | 0, A
SS| 1
(4)
Refer Page No: 285
(OR)
(b) (i) Design a turing Machine M for f(x,y,z)=2(x+y)-z,z<2(x+y) and x,y,z are stored
in the tape in the form 0x10y10z1
(12)
Refer Page No: 341
(ii) Show that if L is accepted by a multi tape turing machine,it is accepted by single
turing machine also
(4)
Refer Page No: 350
15. (a) Find whether the following languages are recursive or recursively enumerable
(i) Union of two recursive languages
(4)
(ii) Union of two recursively enumerable languages
(4)
(iii) L if L and complement of L are recursively enumerable
(4)
(iv) Lu
(4)
Refer Page No: 382
(OR)
(b) (i) Show that “Finding whether the given CFG is ambiguous or not” is undecidable
by reduction technique
(4)
Refer Page No: 387
8
(ii) Consider the Turing Machine M and w=01, Where
M=({q1,q2,q3},{0,1,B},δ,q1,B,{q3}) and δ is given by
qi
δ(qi,0)
q1
q2
q3
δ(qi,1)
δ(qi,B)
(q2,1,R)
(q2,0,L)
(q2,1,L)
(q3,0,L)
(q1,0,R)
(q2,0,R)
-
-
-
Reduce the above problem to Post’s Correspondence Problem and find whether that PCP
has a solution or not
(12)
Refer Page No: 406
9
B.E./B.Tech DEGREE EXAMINATION, NOVEMBER/DECEMBER 2006
Fifth Semester
Computer Science and Engineering
CS1303 – Theory of computation
(Regulation 2004)
PART A – (10 X 2=20 marks)
1. What is the difference between DFA and NFA?

In the state diagram of DFA, for every symbol of the alphabet, we specify its one
and only one state transition. But for NFA, we do not need to specify how does
the NFA react according to some symbol. In the case that the behavior of the
NFA is not specified when read some symbol, we say the NFA (or a branch of
NFA) dies. NFA can specify multiple states that a state can transit to when read a
symbol. (DFA can and an only can specify one next state)

NFA can use the symbol , DFA can not.  means that NFA can generate a new
branch without reading any input symbol

NFA can be understood as some machine that can reproduce itself. Or there will
be multiple little machines computing at the same time, listening to the next
symbol at the same time.

NFA will not reject the input string if one of its branch dies or reject the string.
But if all of the branches of NFA die or reject the string, we say the NFA reject
the string. As long as one branch of the NFA accept the string, we say that the
NFA accept the string.
2. Give regular set for the following expression: 1(01)*(10)*1
Refer Page No: 98
3. For the grammar G defined by S->AB, D->a,A->Aa,A->bB,B->Sb, give derivation
tree for the sentential form babab.
Refer Page No: 192
4. Give pumping lemma to prove that given language L is not context free.
Refer Page No: 140
10
5. Give formal definition of PDA.
A Pushdown Automata M is a system (Q, Σ, Ґ ,δ ,q0, Z0,F) where
Q is a finite set of states.
Σ is an alphabet called the input alphabet.
Ґ is an alphabet called stack alphabet.
q0 in Q is called initial state.
Zo in Ґ is start symbol in stack.
F
is the set of final states.
δ is a mapping from Q X (Σ U {Є} ) X Ґ to finite subsets of Q X Ґ *.
6. Give an example of a language accepted by a PDA but not by DPDA
A PDA P= (Q, Σ, Ґ ,δ ,q0, Z0,F) is deterministic if and only if,
1. δ(q, a, X) has at most one member for q in Q, a in Σ or a= є and X in Ґ
2. If δ(q, a, X) is not empty for some a in Σ, then δ(q, є, X) must be empty.
Refer Page No: 263
7. Prove that the function f(n)=n-1 is computable.
Computable functions are the basic objects of study in computability theory. The
set of computable functions is equivalent to the set of Turing-computable functions and
partial recursive functions. Computable functions are the formalized analogue of the
intuitive notion of algorithm. They are used to discuss computability without referring to
any concrete model of computation such as Turing machines or register machines. Their
definition, however, must make reference to some specific model of computation.
Refer Page No: 369
8. Design a Turning machine to compute n mod 2.
Refer Page No: 330
9. What is undecidability?
An undecidable problem is a decision problem for which it is impossible to
construct a single algorithm that always leads to a correct yes-or-no answer – the problem
is not decidable.
10. Differentiate between recursive and recursively enumerable language.
11
A language is recursive if there exists a Turing machine that accepts every
string of the language and rejects every string (over the same alphabet) that is not in the
language.
A language is recursively enumerable if there exists a Turing machine that
accepts every string of the language, and does not accept strings that are not in the
language. (Strings that are not in the language may be rejected or may cause the Turing
machine to go into an infinite loop.)
Clearly, every recursive language is also recursively enumerable. It is not
obvious
whether
every
recursively
enumerable
language
is
also
recursive.
PART B – (5 x 16 = 80 MARKS)
11. Construct a context free grammar for the given language
L={anbn|/n>=1}U{amb2m/m>=1} and hence a PDA accepting L by empty stack (16)
Refer Page No: 251
12. a) Prove the equivalence of NFA and DFA.
(8)
Refer Page No: 74
b) Prove that a balanced parenthesis is not a regular language.
(8)
Refer Page No: 142
(OR)
a) Explain in detail with an example the conversion of NDFA to DFA
(8)
Refer Page No: 74
b) Show that L = {an! : n>=0} is not regular.
(8)
Refer Page No: 140
13. a) Explain in detail the ambiguity in context free grammar.
(8)
Refer Page No: 219
b) Convert the grammar S->ABb|a, A->aaA|B, B->bAb into greibach normal form. (8)
Refer Page No: 285
(OR)
a) Construct a context free grammar for the languages L(G1)={aib2i/i>0} and
L(G2)={anban/n>0}
(8)
Refer Page No: 191
(b) Prove that {op | p is prime} is not context free.
12
(8)
Refer Page No: 183
14. Construct a Turing Machine to do the proper subtraction
(16)
Refer Page No: 343
(OR)
a) Construct a Turning machine to perform multiplication
(8)
Refer Page No: 345
b) Prove the equivalence of two-way infinite tape with standard Turing machine. (8)
Refer Page No: 350
15. a) Discuss in detail about universal Turing machine.
(8)
Refer Page No: 359
b) Prove that halting problem is undecidable.
(8)
Refer Page No: 397
(OR)
a) Prove that the union and intersection of two recursive languages are also
recursive.
(8)
Refer Page No: 387
b) Prove that there exists an recursively enumerable language whose complement is
not recursively enumerable.
(8)
Refer Page No: 383
13