Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Seat No.: ________ Enrolment No.

___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER– VI (NEW) EXAMINATION – WINTER 2021
Subject Code:3160704 Date:24/11/2021
Subject Name:Theory of Computation
Time:10:30 AM TO 01:00 PM Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
4. Simple and non-programmable scientific calculators are allowed.

MARKS
Q.1 (a) Define one-to-one, onto and bijection function 03
(b) The given relation R on set A= {1,2,3} determine whether the 04
Relation is reflexive, symmetric or transitive, give reason.
R ={(1,1), (1,2), (1, 3),(2,1), (2, 2), (3, 1),(3,3)}
(c) Write Principle of Mathematical Induction. Prove that for 07
every n ≥ 1, 1 + 3 + 5 + … + (2n - 1) = n2

Q.2 (a) Define FA and Write recursive definition of NFA 03


(b) Find a regular expression of following subsets of {0, 1}* 04
1. The language of all strings that begin or end with 00 or 11.
2. The language of all strings ending with 1 and not containing 00.
(c) Draw Finite Automata to accept following over input alphabets Σ ={0, 1} 07
(i) The language accepting strings not ending with ’01’ .
(ii)The language accepting strings next to last symbol ‘0’
OR
(c) Let M1 and M2 be the FAs pictured in Figure, recognizing languages L1 07
and L2 respectively.

Draw FAs recognizing the following languages.


a. L1 U L2
b. L1 - L2

Q.3 (a) Give the difference between moore machine and mealy machine. 03
(b) Define Context Free Grammar. Find context-free grammar for the language: 04
L= {aibjck | j=i+k}

1
(c) Convert NFA- Λ to FA for following figure. 07

OR
Q.3 (a) Define Ambiguous grammar. for following grammar say whether the 03
grammar is ambiguous or not. give reason
SABA, AaA | Λ , BbB | Λ

(b) Design and mealy machine that gives output 1 if input of sequence abb 04
comes, other wise 0.

(c) Find minimum state FA for following figure. 07

Q.4 (a) State pumping lemma for regular languages. 03


(b) Give an unambiguous grammar for SIMPLE CALCULATOR contain +, -, 04
*, /,(,) operator for terminal ‘id’. And draw a parse tree for (id+id)*id-id
(c) Write Kleen’s Theorem part -1. 07
OR
Q.4 (a) Find the CFG for the regular expression : (01*1 + 1)* (01)* 03
(b) Using kleene's Theorem Draw NFA-Λ for ((0+1)*10 + (00)*)* 04
(c) Given the context-free grammar G, find a CFG G’ in Chomsky Normal 07
Form.
S -> AaA | CA | BaB
A -> aaBa | DC
B -> bb | aS
C -> Ca | bC | D
D -> bD | Λ

Q.5 (a) Define Pushdown Automata 03


(b) Design a PDA to accept L = {xcy | x, y∈ (a,b)* and |x| = |y|}. 04
(c) Develop a Turing Machine to accept palindromes over {a,b}* 07
OR
Q.5 (a) Define grammar and Chomsky hierarchy. 03
(b) Design a PDA to accept L = {anbn | n>=0}. 04
(c) Develop a Turing Machine to accept the language L = {X / Na(X)=Nb(X) , 07
X ∈ {a,b}*}

*************

2
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–VI(NEW) EXAMINATION – WINTER 2022
Subject Code:3160704 Date:13-12-2022
Subject Name:Theory of Computation
Time:02:30 PM TO 05:00 PM Total Marks:70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
4. Simple and non-programmable scientific calculators are allowed.

Marks
Q.1 (a) Define the following functions: one-one, on-to, and inverse. 03
(b) Prove “There must be a prime number between n and n!” 04
(c) Write down 5-tuple definition for the finite automata. Construct the 07
minimal finite automata over Σ = {a,b} for the following languages.
L1 = {Where all the strings start and ends with different symbol}
L2 = {Where every string has odd occurrences of “ba”}
.
Q.2 (a) Enlist types of grammars, types of languages and types of automata. 03
(b) Define pumping lemma for regular language. 04
Show that the language L= {anbncn / n>=1} is non-regular using pumping
lemma theory.
(c) Construct the Moore machine that counts the no. of occurrences of 07
substring “bba” over Σ = {a,b}.
Now convert this Moore machine into Mealy machine. Show the transition
table and transition diagram for both the machines.
OR
(c) Define the steps to convert ε -NFA into NFA. Then convert the following 07
ε -NFA into NFA.

Q.3 (a) Define type 2 grammar with example. 03


(b) Construct the regular expressions for the following languages. 04
L1 = {Where the no. of ‘a’ is odd}, Σ = {a,b}
L2 = {Where every string starts with ‘0’ and of even length}, Σ = {0,1}
(c) What is Instantaneous Description? Construct the pushdown automata 07
over Σ = {a,b} for the language L = {an c bn / n>=1}.

1
OR
Q.3 (a) Define the following operations for Push Down Automata: PUSH, POP, 03
and SKIP.
(b) Construct the regular expressions for the following languages. 04
L1 = {Where every string starts with ‘b’ and does not contain 2
consecutive a’s}, Σ = {a,b}
L2 = {Where every string starts with ‘1’ and of odd length}, Σ = {0,1}
(c) Define: CNF. Show the steps to convert CFG into CNF. Convert the 07
following CFG into equivalent CNF.
S→TU
T → 0T1 | ε
U → 1U0 | ε

Q.4 (a) Enlist and explain the operations performed by tape in turing machine. 03
(b) Define pumping lemma for context free language. 04
Show that the language L= {ww / w ∈{a,b}*} is not context free language
using pumping lemma theory.
(c) Explain ambiguous and unambiguous context free grammar with example. 07
OR
Q.4 (a) Enlist closure properties for the context sensitive language. 03
(b) Discuss universal turing machine with example. 04
(c) Write down 7-tuple definition for the turing machine. 07
Construct the turing machine and its transition table over Σ = {a,b} for the
language L = {anbn / n>=1}.

Q.5 (a) State the following functions: Partial, Constant and Total. 03
(b) What is minimization? Explain with suitable example. 04
(c) Discuss Post’s Correspondence Problem with example. 07
OR
Q.5 (a) Define the following terms: Recursive language, and Recursive 03
Enumerable Language.
(b) Explain in detail: Class P and Class NP. 04
(c) Describe: Recursive function. Prove that every recursive function is 07
computable.
***************

2
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–VI (NEW) EXAMINATION – SUMMER 2022
Subject Code:3160704 Date:01/06/2022
Subject Name:Theory of Computation
Time:10:30 AM TO 01:00 PM Total Marks: 70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
4. Simple and non-programmable scientific calculators are allowed.
MARKS
Q.1 (a) Define: Set, Subset, Complement 03
(b) Write and explain the principle of mathematical induction using 04
example.
(c) Draw Finite automata for following regular expression: 07
(i). (0 + 1)∗ (1 + 00)(0 + 1)∗
(ii). (111 + 100)∗ 0

Q.2 (a) Explain Regular language & Regular expressions 03


(b) Find a regular expression corresponding to each of the following 04
subsets of {0,1}*
(i). the language of all strings that do not end with 01
(ii). the language of all strings that begin with or end with 00 or
11
(c) Prove Kleene’s theorem part-1 07
OR
(c) Explain procedure to minimize finite automata 07

Q.3 (a) Define Context free grammar & context free language 03
(b) Write CFG for following 04
(i) L={aibjck | i=j or j=k}
(ii) L={aibjck | j>i+k}
(c) Convert following CFG to CNF : 07
S -> S(S)/^
OR
Q.3 (a) Define Regular grammar and give example. 03
(b) Explain types of derivation and ambiguity. 04
(c) Convert following CFG to CNF : 07
S->aX/Yb X->S/^ Y->bY/b

Q.4 (a) What is a pushdown automaton? Explain. 03


(b) Give the difference between top down and bottom up parsing. 04
(c) Design and draw deterministic PDA Accepting “Balance string of 07
brackets”
OR
Q.4 (a) Explain deterministic pushdown automata. 03
(b) Explain conversion from PDA to CFG. 04
(c) Design and draw PDA to accept string with more a’s than b’s. 07

1
Q.5 (a) What is Turing machine? Explain its capabilities. 03
(b) Explain Church Turing thesis. 04
(c) Design a Turing machine to copy a string. 07
OR
Q.5 (a) Explain Primitive Recursive Functions. 03
(b) Explain Universal Turing machine 04
(c) Design a Turing machine to delete a symbol. 07

*************************

2
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–VI (NEW) EXAMINATION – WINTER 2023
Subject Code:3160704 Date:02-12-2023
Subject Name:Theory of Computation
Time:02:30 PM TO 05:00 PM Total Marks:70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
4. Simple and non-programmable scientific calculators are allowed.
MARKS
Q.1 (a) Say whether the statement (p ᴧ (p → q)) → q is tautology or 03
contradiction.
(b) The given relation R on set A= {1,2,3} determine whether the Relation 04
is reflexive, symmetric or transitive, give reason.
R ={(1,1), (1,2), (2,1), (2, 2), (3,2),(3,3)}
(c) Write Principle of Mathematical Induction. And prove for every n ≥ 1, 07

Q.2 (a) Define FA and Write recursive definition of NFA 03


(b) Find a regular expression of following subsets of {0, 1}* 04
1. The language of all strings that begin or end with 00 or 11.
2. The language of all strings ending with 1 and not containing 00.
(c) Draw Finite Automata to accept following over input alphabets Σ ={0, 1} 07
(i) The language accepting strings not ending with ’01’ .
(ii)The language accepting strings not containing substring ‘00’
OR
(c) Let M1 and M2 be the FAs pictured in Figure, recognizing languages L1 07
and L2 respectively.
M1-- M2--

Draw FAs recognizing the following languages.


a. L1 U L2
b. L1 - L2

Q.3 (a) Find context-free grammar for the language: L= {aibjck | i=j+k} 03
(b) Define mealy machine. Design and mealy machine that gives output ‘x’ if 04
input of sequence is abb, otherwise z.
(c) Convert NFA- Λ to FA for following figure. 07

1
OR
Q.3 (a) Define Ambiguous grammar. for following grammar say whether the 03
grammar is ambiguous or not. give reason
S→ABA, A→aA | Λ , B→bB | Λ
(b) Convert the given Moore machine into Mealy machine. Draw state 04
transition diagram of Mealy machine.

Present Next State Output


State 0 1
→p0 r q0 ɛ
p1 r q0 1
q0 p1 s0 0
q1 p1 s0 1
r q1 p1 0
s0 s1 r 0
s1 s1 r 1
(c) Find minimum state FA for following figure. 07

Q.4 (a) State pumping lemma for context free language. 03


(b) Construct PDA for 04
S → 0AB
A → 1A | 1
B → 0B | 1A | 0
Trace the string 01011 using PDA.
(c) Write Kleen’s Theorem part -1. 07
OR
Q.4 (a) Define Push Down Automata 03
(b) Using kleene's Theorem Draw NFA-Λ for a given RE aa(ba)*+b*aba* 04
(c) Given the context-free grammar G, find a CFG G’ in Chomsky Normal 07
Form.
S -> AaA | CA | BaB
A -> aaBa | DC
B -> bb | aS
C -> Ca | bC | D
D -> bD | Λ

Q.5 (a) Explain Universal Turing Machine 03


(b) Design a PDA to accept L = {xcy | x, y∈ (a,b)* and |x| = |y|}. 04
(c) Develop a Turing Machine to accept palindromes over {a,b}* 07
OR
Q.5 (a) Define grammar and Chomsky hierarchy. 03

2
(b) Design a PDA to accept L = {aibjCk| j = i+k}. 04
(c) Develop a Turing Machine to accept the language L = {X / Na(X)=Nb(X) , 07
X ∈ {a,b}*}

3
Seat No.: ________ Enrolment No.___________

GUJARAT TECHNOLOGICAL UNIVERSITY


BE - SEMESTER–VI (NEW) EXAMINATION – SUMMER 2023
Subject Code:3160704 Date:04-07-2023
Subject Name:Theory of Computation
Time:10:30 AM TO 01:00 PM Total Marks:70
Instructions:
1. Attempt all questions.
2. Make suitable assumptions wherever necessary.
3. Figures to the right indicate full marks.
4. Simple and non-programmable scientific calculators are allowed.

Marks

Q.1 (a) Let f be a function from the set 𝐴 = {1,2,3,4} to 𝐵 = {𝑝, 𝑞, 𝑟, 𝑠} such that, 𝑓 =
03
{(1, 𝑝)(2, 𝑝)(3, 𝑞)(4, 𝑠)}. Is 𝑓 −1 a function?
(b) 𝐿 is defined recursively as follows:
1. 𝜖 ∈ 𝐿
2. ∀𝑥 ∈ 𝐿, both 0𝑥 and 0𝑥1 are in𝐿. 04
Prove that: For every 𝑛 >= 0, every 𝑥 belongs to 𝐿 obtained by n applications
of rule 2 is an element of L.
(c) Discuss “Distinguishability” of one string from another and explain how it
affects the number of states in an FA. Considering the example of 𝐿 =
{𝑎, 𝑏}∗ {𝑎𝑏𝑎}, how do the distinguishable strings in L relate to the number of 07
states in its FA?

Q.2 (a) Define: Grammar. 03


(b) What are similarities and differences between Moore machines and Mealy
04
machines?
(c) Given two languages 𝐿1 and 𝐿2 , defined as:
𝐿1 = {𝑥 | 𝑎𝑙𝑙 𝑥 𝑠𝑡𝑎𝑟𝑡 𝑤𝑖𝑡ℎ 𝑎𝑏𝑎 }
𝐿2 = {𝑥 | 𝑎𝑙𝑙 𝑥 𝑒𝑛𝑑𝑠 𝑖𝑛 𝑏𝑏}
07
Write the regular expression for both the languages and construct FAs 𝑀1 and 𝑀2
such that 𝑀1 accepts 𝐿1 and 𝑀2 accepts 𝐿2 . Derive 𝐿1 ∩ 𝐿2 .

OR

(c) Draw the given NFA in Table-1 and convert it to FA and identify the language.
07
q0 is the initial state and q1 is the accepting state.

Q.3 (a) Draw NFA lambda for the given regular expression:
03
(0)* (00 + 11)* (001) (01 + 10)
(b) Explain the Pumping Lemma for Context Free Languages. 04
(c) Convert the following grammar to CNF.
S → ABA
07
A → aA | ϵ
B → bB | ϵ
OR
Q.3 (a) Find the ꓥ-closure of a set of states for each state of the given NFA lambda in
03
Figure-1.
(b) What are non-CFLs? Give at-least two examples of non-CFLs. 04
(c) Show Bottom Up Parsing of the string “id + id * id” using the following grammar.
E→E+T|T 07
T→T*F|F
1
F → (E) | id

Q.4 (a) Define PDA. State whether a PDA can accept a CFL or not. 03
(b) Discuss the closure properties of CFLs. 04
(c) For the given Turing Machine in Table-2, trace the transition for the strings 1011
and 10101 and identify the language recognized by this TM. TM is defined as TM
07
= (Q, Σ, Γ, q0, δ ) where {q0,q1,q2,q3,q4,q5,q6} ∈ Q, Σ = {0,1}, {0,1,X,Y,B} ∈ Γ,
q0 ∈ Q, B ∈ Γ , B ∉ Σ, {q6} is the accepting state.
OR
Q.4 (a) Compare NPDA with DPDA. 03
(b) Show that if there are strings 𝑥 and 𝑦 in the language 𝐿 so that 𝑥 is a prefix of 𝑦
04
and 𝑥 ≠ 𝑦, then no DPDA can accept 𝐿 by empty stack.
(c) Draw a TM for the Language of strings with balanced parenthesis “(” and “)”
only. 07

Q.5 (a) When can we say that the language is decidable or undecidable? 03
(b) Draw only the transition table of Turing Machine to accept the language 𝐿 = 04
{0𝑛 1𝑛 : 𝑤ℎ𝑒𝑟𝑒 𝑛 ≥ 1}
(c) Define: Bounded Minimalization and show that, if P is a primitive recursive (𝑛 + 07
1) place predicate, its bounded minimalization 𝑚𝑃 is a primitive recursive
function.
OR
Q.5 (a) When can the language be called a recursive language or a recursively enumerable 03
language?
(b) Show that a Turing Machine to recognize the language 𝐿 = 𝐿(0∗ 1) can accept 04
the string without moving the head in L direction.
(c) Define: 𝜇-Recursive functions and show how all computable functions are 𝜇 - 07
recursive.

Table-1 Table-2
𝛿(𝑞, 0) 𝛿(𝑞, 1) State 0 1 X Y B
𝑞0 {𝑞0 , 𝑞1 } {𝑞1 }
𝑞0 (𝑞1, 𝑋, 𝑅) (𝑞2, 𝑌, 𝑅) (𝑞6, 𝑋, 𝑅) (𝑞6, 𝑌, 𝑅) (𝑞6, 𝐵, 𝑅)
𝑞1 {ø} {𝑞0 , 𝑞1 }
𝑞1 (𝑞1, 0, 𝑅) (𝑞1, 1, 𝑅) (𝑞3, 𝑋, 𝐿) (𝑞3, 𝑌, 𝐿) (𝑞3, 𝐵, 𝐿)

𝑞2 (𝑞2, 0, 𝑅) (𝑞2, 1, 𝑅) (𝑞4, 𝑋, 𝐿) (𝑞4, 𝑌, 𝐿) (𝑞4, 𝐵, 𝐿)

𝑞3 (𝑞5, 𝑋, 𝐿) — (𝑞6, 𝑋, 𝑅) (𝑞6, 𝑌, 𝑅) —

𝑞4 — (𝑞5, 𝑌, 𝐿) (𝑞6, 𝑋, 𝑅) (𝑞6, 𝑌, 𝑅) —

𝑞5 (𝑞5, 0, 𝐿) (𝑞5, 1, 𝐿) (𝑞0, 𝑋, 𝑅) (𝑞0, 𝑌, 𝑅) —

Figure-1

=======xx===========xxxxxxxxxxx=======xx======xxxxxxxxxx=============xx=====

You might also like