0% found this document useful (0 votes)
53 views22 pages

Toc Sem Ans-1

A language accepted by a NFA is regular and all regular languages can be accepted by a DFA. To obtain a DFA equivalent to a given NFA, the epsilon-closure of all states needs to be found and used as states for the DFA. The transitions and accepting states are then determined accordingly. For the given NFA, its states would be the epsilon-closures of q0, q1 and q2 and the transitions and accepting states can be determined based on the transitions in the NFA.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views22 pages

Toc Sem Ans-1

A language accepted by a NFA is regular and all regular languages can be accepted by a DFA. To obtain a DFA equivalent to a given NFA, the epsilon-closure of all states needs to be found and used as states for the DFA. The transitions and accepting states are then determined accordingly. For the given NFA, its states would be the epsilon-closures of q0, q1 and q2 and the transitions and accepting states can be determined based on the transitions in the NFA.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

1.

Differentiate DFA and NFA

SR.NO. DFA NFA

NFA stands for


DFA stands for Deterministic Nondeterministic Finite
1 Finite Automata. Automata.

For each symbolic representation No need to specify how does


of the alphabet, there is only one the NFA react according to
2 state transition in DFA. some symbol.

DFA cannot use Empty String NFA can use Empty String
3 transition. transition.

NFA can be understood as


DFA can be understood as one multiple little machines
4 machine. computing at the same time.

In NFA, each pair of state and


In DFA, the next possible state is input symbol can have many
5 distinctly set. possible next states.

6 DFA is more difficult to construct. NFA is easier to construct.

DFA rejects the string in case it NFA rejects the string in the
terminates in a state that is event of all branches dying or
7 different from the accepting state. refusing the string.

Time needed for executing an Time needed for executing an


8 input string is less. input string is more.

9 All DFA are NFA. Not all NFA are DFA.

NFA requires less space then


10 DFA requires more space. DFA.

11. Dead state may be required. Dead state is not required.

δ: QxΣ -> Q i.e. next possible δ: QxΣ -> 2^Q i.e. next possible
12. state belongs to Q. state belongs to power set of Q
2.Draw DFA for language which contain set of strings of 0’s and 1’s start with 01.

3.What is - closure of state in -NFA? Find - closure of state q1 in given -NFA

• ε-closure(q0) = {q0}

• ε-closure(q1) = {q1, q2}

• ε-closure(q2) = {q2}

http://lms.cse.saveetha.ac.in/mod/resource/view.php?id=14610
4.Find the language of given deterministic finite automata

5.Draw NFA for language which contain set of strings of 0’s and 1’s ends with 01.

6.Find the regular language for regular expression (0+1)*00(0+1)*


7.Find the Regular expression for language
a. All strings over {0,1} with the substring ‘010’
b. All strings beginning with ’11 ‘ and ending with ‘0’

8. Construct Î-NFA for regular expression (00+11)

9. State pumping lemma for regular language

For any regular language L, there exists an integer n, such that for all x ∈ L with |x| ≥ n, there
exists u, v, w ∈ Σ∗, such that x = uvw, and

(1) |uv| ≤ n

(2) |v| ≥ 1

(3) for all i ≥ 0: uviw ∈ L

10.When two states are said to be equivalent in NFA?

Let State p and state q are equivalent if for all input strings w , ’(p,w) is in accepting states
then ’(q,w) is also in accepting state otherwise states are distinguishable.

11.Give formal definition of Context free grammar and Find the language of
Grammar S → 0S1 | ε
A context free grammar (CFG) is a forma grammar which is used to generate all the
possible patterns of strings in a given formal language. G is a grammar, which consists
of a set of production rules. It is used to generate the strings of a language.

A context-free grammar (CFG) G is a quadruple (V, T, P, S) where

V: a set of non-terminal symbols

T : a set of terminals (V ∩ T = Ǿ)

P: a set of rules (P: V → (V U Σ)*)

S: a start symbol.

Find the language of Grammar

S → 0S1 | ε

Solution:

Given G = ({S}, {0,1}. {S → 0S1 | ε }, S)


ε in L(G) because S →ε .
01 in L(G) because S →
0S1→ 01. 0011 in L(G)
because
S → 0S1→ 00S11→ 0011.
0n 1n in L(G) because S
*→ 0n 1n . L(G) = {0 n 1n |
n > 0}

12.Consider G have productions


1. E → E + E
2. E → E * E
3. E → a | b | c
Find the leftmost derivation for a*b+c
Leftmost Derivation – Process of deriving a string in which left most variable is replaced
by each step.
E→ E*E
→ a*E
→ a * E +E
→ a * b +E
→ a*b+c

14.When CFG is said to be ambiguous? Check whether the given grammar G is ambiguous
or not.

1. S → aSb | SS
2. S → ε
Ambiguous grammar : Let G= <V,T,P,S> be a grammar is said to be
ambiguous if there is at least a string w in T* have more than one parse
trees ,each with root labelled S and yield w.

1. S → aSb | SS
2. S → ε
Solution : take string aabb, derived from two ways

Here are two parse trees for a single string "aabb", the grammar G is ambiguous.

13. Find the derivation tree for string abb using grammar

S → AB | ε

A → aB

B → Sb

Solution: LMD

RMD
14.When PDA is said to be Deterministic PDA?

A PDA P = (Q, , Γ, δ, q0, Z0, F) to be deterministic if and only


if it satisfies the following conditions
1)  (q,a,X) has at most one member for any q in Q, a in  or and X in
Γ
2)  (q,a,X) is non empty for some a in  then
 (q, , X ) must be empty

15. Which of the functions are performed by the Turing Machine after reading a
symbol?

16.Examine the transition function of Turing machine M to compute f(x) =x+1.

17. How to describe ID of Turing machine?

ID's for TM's are strings of the form α –q– β , where α, β ∈ Γ* and q ∈ Q. ... The string β
represents the non-blank tape contents to the right of the head, including the currently
scanned cell. Adding or deleting a few blank symbols at the beginning of an ID results in an
equivalent ID.
18. Compare Multi-tape Multi-head Turing Machine and Single tape Turing
Machine

• It has multiple tapes and controlled by a single head.


• The Multi-tape Turing machine is different from k-track Turing machine
but expressive power is same.
• Multi-tape Turing machine can be simulated by single-tape Turing
machine.

• A multi-head Turing machine contain two or more heads to read the


symbols on the same tape.
• In one step all the heads sense the scanned symbols and move or write
independently.
• Multi-head Turing machine can be simulated by single head Turing
machine.
• What is a single tape Turing machine?
• A single tape Turing Machine M has two states q0 and q1, of which q0 is the
starting state. The tape alphabet of M is {0, 1, B} and its input alphabet is {0,
1}. The symbol B is the blank symbol used to indicate end of an input string.

19.Draw the transition diagram of Turing Machine to accept L={strings over 1


containing even number of 1's}

20.When problem is said to be un-decidable? Give suitable example for un-


decidable problem

A problem whose language is recursive is said to be decidable. 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.

21. Examine the properties of recursive enumerable languages

A recursively enumerable language is a formal language for which there exists a Turing
machine (or other computable function) that will halt and accept when presented with any
string in the language as input but may either halt and reject or loop forever when presented
with a string not in the language.
22. Find whether the lists M = (ab, bab, bbaaa) and N = (a, ba, bab) have a Post
Correspondence Solution?

Let’s explore that the lists M = (ab, bab, bbaaa) and N = (a, ba, bab) include a Post
Correspondence Solution?

x1 x2 x3

M ab bab bbaaa

N a ba bab

So it doesn’t include a solution because −

| (Lengths are not same)


Hence, it can be said that this Post Correspondence Problem is undecidable.

23. Differentiate class P and NP problems


24. Illustrate tractable and intractable problems with example.

Tractable Problem: A problem that is solvable by a polynomial-time algorithm.


The upper bound is polynomial.
Here are examples of tractable problems (ones with known polynomial-time algorithms):
– Searching an unordered list
– Searching an ordered list
– Sorting a list
– Multiplication of integers (even though there’s a gap)
– Finding a minimum spanning tree in a graph (even though there’s a gap)

Intractable Problem: a problem that cannot be solved by a polynomial-time


algorithm. The lower bound is exponential.
From a computational complexity stance, intractable problems are problems for
which there exist no efficient algorithms to solve them.
Most intractable problems have an algorithm that provides a solution, and that
algorithm is the brute-force search.
This algorithm, however, does not provide an efficient solution and is, therefore, not
feasible for computation with anything more than the smallest input.

Examples
Towers of Hanoi: we can prove that any algorithm that solves this problem must have
a worst-case running time that is at least 2n − 1.
* List all permutations (all possible orderings) of n numbers.
UNIT 1
PART B – 13 MARKS

1. (i) Prove that If a language L is accepted by a NFA then there exists a DFA that
accepts L.

(ii) Obtain DFA for NFA for the following

Link to download the PDF : https://rb.gy/lncr8y - Page no : 1-3

2. Design £-NFA for language L which accept any number of a’s followed by any
number of b’s followed by any number of c’s and Construct the DFA for the obtained
£-NFA.

Link to download the PDF : https://rb.gy/lncr8y - Page no : 11-13

3. Construct NFA for the following -NFA and check input abb is accepted or not.

Link to download the PDF : https://rb.gy/lncr8y - Page no : 14


UNIT 1I
PART B – 13 MARKS

1. Find the regular expression for the following finite automata

Link to download the PDF : https://rb.gy/lncr8y - Page no : 19 & 20

2. Construct -NFA for regular expression (a+b)*abb. Construct DFA for the obtained
- NFA.

Link to download the PDF : https://rb.gy/lncr8y - Page no : 21 - 23

3. Examine the closure properties of Regular Languages.

Link to download the PDF : https://rb.gy/asrijw


UNIT 3
PART B

ANS : https://rb.gy/vi2vij - Page : 2 & 3

ANS : https://rb.gy/vi2vij - Page : 11 & 12

ANS : https://rb.gy/vi2vij - Page : 10 & 11


UNIT 4

Part-b

1) Design a Turing Machine to accept L={0n1 n |n>=0} and illustrate the process of input string ‘
0011’ by Turing Machine.

https://drive.google.com/file/d/1aEtlQbKLtKCVaM3Gd6Njbu_mPmkN2UUr/view?usp=sharing

page no:11

2) Examine in detail about Multi-head and Multi-tape Turing Machine.

https://drive.google.com/file/d/1aEtlQbKLtKCVaM3Gd6Njbu_mPmkN2UUr/view?usp=sharing

page no:5

3) State Halting problem in Turing Machine. Prove that Halting Problem is un-decidable.

https://www.geeksforgeeks.org/halting-problem-in-theory-of-computation/

Part c

1) Explain the basic model of Turing Machine. Construct a Turing Machine to accept Language L={anb
n c n / n>0}.

https://drive.google.com/file/d/1aEtlQbKLtKCVaM3Gd6Njbu_mPmkN2UUr/view?usp=sharing

page no:13

UNIT 5

Part-b

1) Prove that Lu is recursive enumerable but not recursive.

http://www.cs.columbia.edu/~aho/cs3261/Lectures/L16-
Universal_Language.html#:~:text=The%20Universal%20Language%20L&text=Lu%20is%20recursively
%20enumerable,accepted%20by%20that%20Turing%20machine.

2) Explain the encoding process of Turing Machine. Find the encoding of TM M =(


Q={q1,q2,q3}, ={0,1},={0,1,B},,q1,B,{q2}) whose transitions are given below  (q1,1) =
(q3,0,R)  (q3,0) = (q1,1,R)  (q3,1) = (q2,0,R)  (q3,B) = (q3,1,L)

https://drive.google.com/file/d/1WiJ5NWcTfxOngIVNTHoy-1r0YlQ_vmzn/view?usp=sharing

page no 3

3) State Post Correspondence Problem (PCP) and Prove PCP is un-decidable.

https://drive.google.com/file/d/1WiJ5NWcTfxOngIVNTHoy-1r0YlQ_vmzn/view?usp=sharing

page no 18 and 30
PART-C

UNIT – I

1. Construct a DFA equivalent to the following NFA whose transition diagram is shown
below
State 0 1
p {p,q} {p}
q {r} {r}
r {s}
*s {s} {s}
http://lms.cse.saveetha.ac.in/mod/folder/view.php?id=14964 topic 4 pdf page number :1..
UNIT –II
Construct -NFA for regular expression (a+b)*baa. Construct a minimized DFA for the
obtained -NFA
(There is a slight changes instead of abb use baa)
UNIT –III
2. Convert the PDA P=({p,q},{0,1},{X,Z0}, ,q,Z0) to a CFG if is given by
1) (q,1, Z0) = (q,XZ0)
2) (q,1,X) = (q,XX)
3) (q,0,X) = (p, )
4) (p,0,X) = (p, )
5) (p, , ) = (p, )
http://lms.cse.saveetha.ac.in/mod/resource/view.php?id=14887

UNIT –IV

Explain the basic model of Turing Machine. Construct a Turing Machine to accept
Language L={anbncn / n>0}.
https://drive.google.com/file/d/1aEtlQbKLtKCVaM3Gd6Njbu_mPmkN2UUr/view?usp=sha
ring

UNIT – V

1. State and prove the properties of recursive and recursive enumerable languages.

http://lms.cse.saveetha.ac.in/mod/folder/view.php?id=26303
(Undecidability pdf ) page no:3

You might also like