TOC AnswerKey
TOC AnswerKey
Fifth Semester
Information Technology
THEORY OF COMPUTATION
(2013 – 14 Regulations)
1. Construct a NFA that accepts the set of all strings with an even number of zero’s and an
even number of 1’s.
L={1,111,01,001,0111,0010,01110,….}
Definition A Mealy Machine changes its output A Moore Machine’s output depends only on
on the basis of its present state and the current state. It does not depend on the
current input. current input.
Output Mealy Machine places its output on Moore machine also places its output on the
the transition. transition.
States It has comparatively fewer or the same It has comparatively fewer or the same
states as that of the Moore machine. states as that of the Mealy machine.
Requirement of A Mealy Machine generally requires The states for synthesis required for this
States only a very few states for the process machine are also more.
of synthesis.
4. List the regular expression operators and state their order of precedence.
()>*>.>+
Star (*)
Concatenation ( .)
Union (+)
5. For the following grammar, find the leftmost and rightmost derivations for the string,
+*xyxy
E +EE | *EE |x|y.
Example of Turing machine accepting a string with equal numbers of zeros and
ones - this can't be done with FA, as was previous shown.
Programming Turing machine can be done entirely in finite state logic, but can
also be done with information on tape.
Finite state logic can also be used to store information, by including tape symbol
dependent states.
A Handle is a substring that matches the body of a production. Handle reduction is a step
in the reverse of rightmost derivation. A rightmost derivation in reverse can be obtained
by handle pruning.
PART B – (5 * 11 = 55 marks)
Answer ALL questions.
UNIT – I
11. State the difference between 𝜺-NFA, NFA and DFA. Convert the above given 𝜺-NFA to
NFA.
12. Represent the following NFA using a transition diagram. Construct a DFA equivalent to
the NFA given below.
ᵟ 0 1
P {P,Q} P
Q R R
R S ᵠ
*S S S
UNIT II
Or
14. Convert the given CFG to GNF
S ABA
AaA|𝜺
BaB|𝜺
UNIT III
15. Write in detail about recursive languages and recursively enumerable languages. Also
explain briefly about the Church Turing hypothesis.
i.e. The TM can halt in the accepting state but need not halt in the non accepting state.
i.e. Here the TM can halt (1) in the accepting states and (2) in the non accepting state.
Result 1:
If a language is recursive then it is recursive enumerable.
Result 2: Recursive languages are closed under complementation.
Proof: Let L be a recursive language. Then there is a Turing Machine M that accepts L.
.
Construct a Turing machine M’ from M such that : M enters a final state on the input W
in L, then M’ halts in a non accepting state. (Without accepting)
If M halts without accepting then M’ accepts the input ‘w’ in L’. Hence M’ is an algorithm
and is given as below.
W Yes Yes
M
Start No No
Here ‘Yes’ corresponds to ‘accept’ and ‘No’ corresponds to ‘Reject’. The language of M’ is
L (M’) and is the complement of L. Hence the proof.
Proof: Let L1 and L2 two recursive languages. Then there exists Turing machine M1 and M2 such
that M1 and M2 accept L1 and L2 respectively.
Since M1 and M2 are algorithms (used to say Yes or No), M1 and M2 will not hang, they will halt (in
accepting state or non accepting state). M will surely halt (It will not hang).
Hence M is an algorithm. M is given below:
W
Yes
M1 No
Start
Start
M2 No
There are Turing machine M1 and M2 such that M1 accepts L1 and M2 accepts L2. Construct a
Turing machine M that accepts L1U L2 as below:
The above procedure will not work here. Since M1 may not halt for some input W in L1. Hence
M is constructed as below
M1 Yes
Yes
M2 Yes
Result 5: If a language L and its complement L’ are both recursively enumerable, then L ( and
hence L’ by result 2 ) is recursive.
To prove: L is recursive
Proof: Let a language L and its complement L’ are recursively enumerable. Then there are Turing
machine M1 and M2 that accepts L and L’ respectively.
Construct a Turing machine M that accepts L and say either ‘Yes’ or ‘No’ as below: M is
connected in such a way that M simulate M1 and M2 simultaneously.
If M1 accepts then M will accept it.
If M2 accepts then M will reject it.
Hence M will always say either ‘yes’ or ‘no’ and not both.
Hence M is an algorithm that accepts that accepts L. Hence L is recursive. {Proved Ans (1) } Hence
L’ is recursive. {Ans (2)}
M is shown below:
M1 Yes Yes
W
Start
M2 Yes No
CHURCH–TURING’S THESIS
Alan Turing defined Turing machines in an attempt to formalize the notion of an “effective
producer” which is usually called as ‘algorithm’ these days. Simultaneously mathematicians were
working independently on the same problem.
All of the above formalisms were proved equivalent to one another. This led to
(a) Turing’s Thesis (Weak Form): A Turing machine can compute anything that can be
computed by a general-purpose digital computer.
(b) Turing’s Thesis (Strong Form): A Turing machine can compute anything that can be
computed.
The strong form of Turing’s Thesis cannot be proved it states a relationship between
mathematical concepts and the “real world”.
1.4.1 Counting
Two sets can be put into a one-to-one corresponding if and only if they have
exactly the same number of elements.
Example: {red, yellow, green, blue}
{1, 2, 3, 4}
1.4.2 Recursive and Recursively Enumerable Language
There are three possible outcomes of executing a Turing machine over a given
input.
The Turing machine may
(i) Halt and accept the input
(ii) Halt and reject the input, or
(iii) Never halt.
A language is “recursive” if there exists a Turing machine that accepts every string of
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 which are
not in the language may be rejected or may cause the Turing machine to go into an infinite loop.
Every Recursive language is also recursively enumerable. But it is not clear if every
recursively enumerable language is also recursive. Turing Machines are not “recursive”. The
terminology is borrowed from recursive function theory.
Or
16. Construct a Turing machine for
L = {aibjck | i*j = k, i, j, k>=1}
UNIT IV
17. Construct a PDA by empty stack, that accepts the language recognized by the grammar,
S 0S1 | A
A 1A0 | S | 𝜺
Check whether the string 0101 is accepted by that PDA.
1. S → 0S1 | 1S0 | ε
1. S → 0SX | 1SY | ε
2. X → 1
3. Y → 0
Or
18. Design a PDA which accepts all strings which can be derived from the following
Grammar Taking a suitable example string, verify the machine.
S 0B | 1A
A 0 | 0S | 1AA
B 1 | 1S | 0BB
UNIT V
19. Check whether the following grammar is a LL(1) grammar. Also define the FIRST and
FOLLOW prodecures.
S iEtS | iEiSeS | a
Eb
Or
20. Construct the CLR and LALR parsing table for the following grammar.
S CC
C cC
Cd