Cs3452 Theory of Computation
Cs3452 Theory of Computation
CS3452-THEORY OF COMPUTATION
Question Bank
To equip students with values, ethics and life skills needed to enrich their lives and
M3
enable them to meaningfully contribute to the progress of society
M4 To prepare students for higher studies and lifelong learning, enrich them with the
practical and entrepreneurial skills necessary to excel as future professionals and
contribute to Nation’s economy
Vision of Department
To emerge as a globally prominent department, developing ethical computer professionals,
innovators and entrepreneurs with academic excellence through quality education and research .
Mission of Department
M3 To produce engineers with good professional skills, ethical values and life skills for the
betterment of the society.
PEO3 Apply ethical knowledge for professional excellence and leadership for the
betterment of the society.
PEO4 Develop life-long learning skills needed for better employment and
entrepreneurship
Program Specific Outcomes (PSOs)
An ability to understand the core concepts of computer science and engineering and to
PSO1 enrich problem solving skills to analyze, design and implement software and hardware
based systems of varying complexity.
To interpret real-time problems with analytical skills and to arrive at cost effective and
PSO2 optimal solution using advanced tools and techniques.
BTL6: Creating.,
BTL 5: Evaluating.,
BTL 4: Analyzing.,
BTL 3: Applying.,
BTL 2: Understanding.,
BTL 1: Remembering
SYLLABUS
UNIT V UNDECIDABILITY 9
Unsolvable Problems and Computable Functions –PCP-MPCP- Recursive and recursively enumerable
languages – Properties - Universal Turing machine -Tractable and Intractable problems - P and NP
completeness – Kruskal’s algorithm – Travelling Salesman Problem- 3-CNF SAT problems.
OUTCOMES:
At the end of this course, the students will be able to:
C211.1: Construct automata theory using Finite Automata
C211.2: Write regular expressions for any pattern
C211.3: Design context free grammar and Pushdown Automata
C211.4: Design Turing machine for computational functions
C211.5: Differentiate between decidable and undecidable problems
TOTAL:45 PERIODS
INDEX
Unit # Ref. Book
J.E.Hopcroft, R.Motwani and J.D Ullman, “Introduction to Automata
Need for automata theory - Introduction to formal proof – Finite Automata (FA) – Deterministic Finite
Automata (DFA) – Non-deterministic Finite Automata (NFA) – Equivalence between NFA and DFA –
Finite Automata with Epsilon transitions – Equivalence of NFA and DFA- Equivalence of NFAs with and
without ε-moves- Conversion of NFA into DFA – Minimization of DFAs.
If S(i) is true for n = i ,then it is to be proved that for all n > i , S(n) implies C211.1 BTL 1
S(n+1) then S(n) is true for all n ≥ i..
Construct a DFA for the language over {0, 1}* such that it contains
“000” as a substring. APR/MAY 2011
C211.1 BTL 3
1 0,1
6
Q 0 Q 0 0Q 0 Q0
0 1 2 3
1 1
Design DFA to accept strings over ∑ = (0,1) with two consecutive 0’s.
NOV/DEC 2014 C211.1 BTL 3
1 0,1
16
q0 q1 q3
0 0
Construct a DFA that accepts input string of 0,s and 1’s that end
with 11. 0
C211.1 BTL3
1 1
21
q0 q1 q2
0 1
0
Define TOC
Theory of Computation is the branch that deals with how efficiently
C211.1 BTL3
28 problems can be solved on a model of computation, using an algorithm.
The field is divided into three major branches: automata theory,
computability theory, and computational complexity theory.
Give some examples for additional forms of proof.
29 1. Proofs about sets 2. Proofs by contradiction 3. Proofs by counter
C211.1 BTL3
examples.
30 1 1 1 1
1 q0 q1 q1 q3
- First find out which two states are equivalent we than replace those
31 two states by one representative state.
- For findingthe equivalent states we will apply the followingrule - The
two states S1 & S2 are equivalent if and only if both the states arefinal
or non-final
PART B
1 Explain the different forms of proof with examples. (8)
NOV/DEC 2012
C211.1 BTL 1
2 Prove that, if L is accepted by an NFA with ε-transitions, then L is
accepted by an NFA without ε-transitions.(8) NOV/DEC 2012,
C211.1 BTL 1
NOV/DEC 2013
3
Convert an NFA to a DFA given NFA M = (Σ,Q,δ,q0, F) Σ={0,1},
Q = { q0, q1, q2 ,q3},F= { q0}, C211.1 BTL 3
5
Prove by induction on n that (6)
C211.1 BTL 3
MAY/JUNE 2012
6 Construct an NFA without ε-transitions for the NFA give below. (8)
MAY/JUNE 2012
C211.1 BTL 3
0 1
Q ε Q
1
0
10 Prove that there exists a DFA for every NFA.(8) MAY/JUNE 2013,
NOV/DEC 2018
C211.1 BTL 4
11 (i) Prove that every tree has ‘e’ edges and ‘e+1’ nodes.
NOV/DEC 2014
C211.1 BTL 4
2n+1 n+2
(ii) Prove that for every integer n>=0 the number 4 +3
is a multiple of 1 NOV/DEC 2014
C211.1 BTL 3
1
1D 0 1
ɛ ɛ
A B C
State a b
C211.1 BTL 3
*1 2 3
2 4 5
3 6 7
4 5 4
5 7 5
6 2 7
*7 7 4
a b C211.1 BTL 3
q0 q1 q0
q1 q0 q2
q2 q3 q1
*q3 q3 q0
q4 q3 q5
q5 q6 q4
q6 q5 q6
q7 q6 q3
Write Regular Expression for the set of strings over {0.1} that BTL 3
have atleast one. NOV/DEC 2015
3
Regualr Expression = (0+1)*1
Give a regular expression for the set of all strings having odd C211.2
5 number of 1’s
BTL 3
RE= 1(0+11)*
Give the regular expression for the set of all strings ending in C211.2
6 00.
BTL 3
Regular expression = (0+1)*00
What are the applications of regular expression? C211.2
7 Regular expression in UNIX, Lexical analysis, Pattern searching
BTL 4
example : 0* ={ ε,0,00,000,…………………………………}
10 Language includes empty words also.
example : 0+ ={ 0,00,000,…………………………………}
Language includes empty words also.
Construct a r.e for the language over the set ={a,b} in which C211.2 BTL 3
11 total number of a’s are divisible by 3
( b* a b* a b* a b*)*
Regular expression denoting a language over ∑ ={1} having (i) C211.2 BTL 3
even length of string (ii) odd length of a string.
12 (i) Even length of string R=(11)*
What are the three methods of conversion of DFA to RE? C211.2 BTL 1
q
1
Let L = {w:w ε {0,1}* w does not contain 00 and is not empty}. C211.2 BTL 3
Construct a regular expression that generates L. APR/MAY
21 2010
Prove or disprove that the regular languages are closed under C211.2 BTL 4
concatenation. APR/MAY 2010.
23
Q 0,1 Q 0 Q 1 Q
0 1 2
3
Is the set of strings over the alphabet {0} of the form 0n where n C211.2 BTL 4
is not a prime is regular? Prove or disprove. NOV/DEC 2011
Assume that the set is regular. Let p be the pumping length of the
24 language. Then, according to the pumping lemma, break the string
s=0p into s=xyz where y has positive length.
Then, s=xyi z=0p+(i-1)|y| must also be in the set for any i. In particular
let i=p+1.Then xyp+1z=0p+p|y| must be in the set so p+p|y| = p(1+|y|)
must be prime. Thus we have a contradiction and the set cannot be
regular.
25 State pumping lemma for regular set. NOV/DEC 2010, C211.2 BTL 1
NOV/DEC 2013,NOV/DEC 2014
Let R be any set of regular languages. Is U(R) regular? Prove C211.2 BTL 4
it.
Write the regular expression for the language in which every C211.2 BTL 3
string will have at least one ‘a’ followed by at least one ‘b’.
The regular expression for the language in which every string will
28 have at least one ‘a’ followed by atleast one ‘b’ is given as: R=a+ b+
.
PART B
1 C211.2
Obtain the regular expression that denotes the language accepted
by BTL 3
2 C211.2
Using pumping lemma for regular sets. Prove that the language
L = {anbn /n>=1} is not regular BTL 3
7 What is Regular Expression? Write a regular expression for set C211.2 BTL 3
of strings that consists of alternating 0’s and 1’s. (8)
MAY/JUNE 2016
8 C211.2 BTL 1
9 Discuss the basic approach to convert from NFA to regular C211.2 BTL 1
expression. Illustrate with an example. (16)
NOV/DEC 2016
10 Show that the given two regular Languages are equivalent C211.2 BTL 4
(a+b)*
(a*+b*)*
12 Prove that there exists an NFA with ε-transitions that accepts C211.2 BTL 1
the regular expression γ. (10)
MAY/JUNE 2012, NOV/DEC 2010
C211.2 BTL 3
14
Obtain the regular expression for the finite automata.
(8) MAY/JUNE 2012
a a
q0 b q1 b q2
15 Construct a minimized DFA from the regular expression C211.2 BTL 3
(i) (b/a)*baa
(10) MAY/JUNE 2012
(ii) 0*(01)(0/111)*
(16) NOV/DEC 2012
(iii) (x+y)x(x+y)*. Trace for a string w=xxyx.
(16) NOV/DEC 2011
(iv) (a+b)(a+b)* and trace for a string baaaab.
(16) APR/MAY 2010
(v) (b/a)*baa
(16) NOV/DEC 2010
(vi) 10+(0+11)0*1
(16) NOV/DEC 2014
16 Construct a regular expression for the following DFA using C211.2 BTL 3
kleene’s theorem. (10) APR/MAY 2011
0 1
*A A B
B C B
C A B
17 Construct a ε-NFA for the following regular expression. (6) C211.2 BTL 3
APR/MAY 2011
(0+1)*(00+11)(0+1)*
18 C211.2 BTL 3
19 State and explain the conversion of DFA into regular C211.2 BTL 1
expression using Arden’s theorem. Illustrate with an example.
(16) NOV/DEC 2011
21
22
B->1B|ε
S=> aB
4 aaBB
aaaBBB
aaabBB
aaabbSB
aaabbaBB
aaabbabB
aaabbabbS
aaabbabbbA
aaabbabbba
Let G = {{s,c},{a,b},P,S} where P consists of S->aCa, C211.3
C->aCa|b Find L(G).
5 BTL 3
S->aCa->aaCaa->aaaCaaa->…..->aicai->anban(C->b)
L(G) = {anban |n>=1}
LMD:
S=>A1B=>0A1B=>00A1B=>001B=>0010B=>00101B=>0010
1
RMD:
S=>A1B=>A10B=>A101B=>A101=>0A101=>00A101=>001
01
Show that id+id*id can be a ambiguous one for the grammar C211.3
E->E+E/ E*E/ (E)/id
BTL 3
LMD 1
8 EE+E id+Eid +E*E id +id*Eid +id*id
LMD 2
EE*EE+E*Eid+E*Eid+id*Eid+id*id. Therefore id+id*id
can be generated by two distinct LMD .Thus it is ambiguous.
1. Stack which is used to store the necessary tape symbols and C211.3 BTL 1
19 use the state to remember the conditions.
2. Two ways of language acceptances, one reaching its final
state and another by emptying its stack.
22 δ:Q X (∑ U {ε}) X Г Q X Г*
29 The properties are: 1. Each variable and each terminal of G appears C211.3 BTL 1
in the derivation of some word in L 2. Here are no productions of the
form A->B where A and B are variables
The PDA usually consists of four components: A control unit. C211.3 BTL 1
30
A Read Unit. An input tape.
A Memory unit.
S=>bSa=>bbSa=>bbaTa=>bbaa
The grammar generates two parese tree for the string ababa
S S
32
S b S S b S
a S b S S b S
a a a a
SaS|bS|a|b
δ (q,ɛ,S)={(q,aS),(q,bS),(q,a),(q,b)}
δ (q,a,a)=(q, ɛ)
δ (q,b,b)=(q, ɛ)
PART – B
1 Consider the following grammar for list structures:
2. SaSb|ab
SaSb|ab
ED|(E)|E+E|E-E|E*E|E/E
D0|1|2|….9
Find a parse tree for the string 1+2*3 NOV/DEC 2015
6 Let G=(V,T,P,S) be a Context free grammar then prove
that if the recursive inference procedure tells us that
C211.3 BTL 4
terminal string W is in the language of variable A, then
there is a parse tree with root A and yield w.
NOV/DEC 2015
Aa|aS|bAA
Bb|bS|aBB
B->0B|1B|0|1
BbBb|a
CCA|AC
S BaB
A aA|aaa
BbBb|a
Sa
Q – {q0,q1,q2}
∑ - {a,b}
Г – (a,b,B}
q0 – Initial state
q2 - Final state
δ(q0,a) = (q1,a,R)
δ(q1,a) = (q1,a,R)
δ(q1,b) = (q1,b,R)
δ(q1,B) = (q2,B,R)
δ:Q X Г Q X Г X {L,R,S}
q0 – Initial state
B ε Г – Blank Symbols
F - Final state
SaAa | bBb |€
AC|a
BC|b
CCDE | €
DA|B|ab
AaA|Bac|aaa
BbBb|a|D
C->CA|AC
Dɛ
Reverses the given string {abb}. (8) NOV/DEC 2012 C211.4 BTL 3
UNIT V UNDECIDABILITY
Non Recursive Enumerable (RE) Language – Undecidable Problem with RE – Undecidable Problems
about TM – Post‘s Correspondence Problem, The Class P and NP.
PART - A
16 Y N
w M
Y
N
17 Write the properties of Recursive Languages. C211.5
a formal language is recursive if there exists a total Turing
machine (a Turing machine that halts for every given input) that,
when given a finite sequence of symbols as input, accepts it if it
belongs to the language and rejects it otherwise. Recursive
languages are also called decidable.
When do you say a problem is NP - hard? C211.5
18 A problem is said to be NP - hard if an algorithm for solving it can
be translated into a problem which is NP problem. Thus NP - hard is
a algorithm for a problem which is atle
When a problem is said to be undecidable? C211.5
19
If a problem is not a recursive language, then it is said to be
undecidable problem
What is diagonalization language? C211.5
20 The language Ld Which consists of all those strings w such that the
Turing machine represented by w does not accept the input w.
Ld = { wi | wi L(Mi)}
Define Problem Solvable in Polynomial Time C211.5
21 A Turing Machine M is said to be of time complexity T(n) if
whenever m given an input w of length n, m halts after making at
most T(n) moves, regardless of whether or not m accepts.
Show that union of recursive language is recursive C211.5
L1 and L2 are recusive language. Then there exists a machine M1
that accepts L1 as well as machine M2 that accepts L2. We can
22 simulate a machine M that accepts the language L such that L = L1
U L2. Then construct M which accepts if M1 accepts. If M1 does
not accept then M2 simulates M. That means if M2 accepts then M
accepts, if M2 rejects M also rejects. Thus M accepts the language L
= L1 U L2 which is recursive.
Define NP-Completeness. C211.5
23 A language is NP-complete if the following statements are true.(i)L
is in NP (ii)For every language L‟ in NP there is a polynomial time
reduction of L‟ to L.
What is the difference between PCP and MPCP? C211.5
24
The difference between MPCP and PCP is that in the MPCP ,a
solution is required to start with the first string on each list.
What are the concepts used in UTMs? C211.5
25
Stored program computers. Interpretive Implementation of
Programming languages. Computability
Define L .When is a trivial property? C211.5
26
L is defined as the set { | L(M) is in . } is a trivial property if is
empty or it consists of all r.e languages
When we say a problem is decidable? Give an example of C211.5
undecidable problem?
A problem whose language is recursive is said to be decidable.
27 Otherwise the problem is said to be undecidable. Decidable
problems have an algorithm that takes as input an instance of the
problem and determines whether the answer to that instance is “yes”
or “no”. (eg) of undecidable problems are (1)Halting problem of the
TM.
28 Define the class NP Problem. C211.5
A problem is said to be NP if 1. its solution comes from a finite set
of possibilities, and 2. it takes polynomial time to verify the
correctness of a candidate solution. Example - Scheduling problems.
What are tractable problems and intractable problems? C211.5
Tractable Problem: a problem that is solvable by a polynomial-time
29
algorithm. The upper bound is polynomial. Intractable Problem: a
problem that cannot be solved by a polynomial-time algorithm. The
lower bound is exponential.
What are the properties of recursive and recursively enumerable
languages?.
(i)The complement of a recursive language is recursive,(ii)The union C211.5 BTL 1
30
of two recursive languages are recursive. (iii)The union of two
recursively enumerable languages are recursively enumerable.(iv)If
a language L and are both recursively enumerable then L is
recursive.
PART – B
Explain any four NP-Complete Problems.
1 (8)NOV/DEC 2010,NOV/DEC 2013
C211.5 BTL 3
Prove that “MPCP reduces to PCP”. NOV/DEC 2015
2
C211.5 BTL 1
State and prove the Post’s correspondence problem.
3 (10)NOV/DEC 2012, NOV/DEC 2014
C211.5 BTL 3
Write a note on NP problems.
4 (6) NOV/DEC 2012
C211.5 BTL 1
Explain undecidability with respect to post correspondence
5 problem. (8) MAY/JUNE2012
C211.5 BTL 1
6 Show that the union of two recursive language is recursive &
union of two recursively enumerable languages is recursive.
C211.5 BTL 1
(12) NOV/DEC 2014
9 Prove that for two recursive languages L 1 and L2 their union and
intersection is recursive. NOV/DEC 2013,NOV/DEC
C211.5 BTL 1
2014,NOV/DEC 2018