2160704
2160704
Rationale: Theory of computation teaches how efficiently problems can be solved on a model
of computation, using an algorithm. It is also necessary to learn the ways in which computer can be made to
think. Finite state machines can help in natural language processing which is an emerging area.
Content:
Note: This specification table shall be treated as a general guideline for students and teachers. The actual
distribution of marks in the question paper may vary slightly from above table.
Reference Books:
1. An introduction to automata theory and formal languages By Adesh K. Pandey, Publisher: S.K.
Kataria& Sons
2. Introduction to computer theory By Deniel I. Cohen , Joh Wiley & Sons, Inc
3. Computation: Finite and Infinite By Marvin L. Minsky Prentice-Hall
4. Compiler Design By Alfred V Aho, Addison Weslley
5. Introduction to the Theory of Computation By Michael Sipser
6. Automata Theory, Languages, and Computation By John Hopcroft, Rajeev Motowani, and Jeffrey
Ullman
Course Outcome:
1. At the end of the course the students will be able to understand the basic concepts and application
of Theory of Computation.
2. Students will apply this basic knowledge of Theory of Computation in the computer field to solve
computational problems and in the field of compiler also.
1. http://en.wikipedia.org/wiki/Theory_of_computation
2. http://meru.cecs.missouri.edu/courses/cecs341/tc.html
ASSIGNMENT - 1
Department: Computer Science and Engineering
Name of Subject In charge: Farhin Mansur
Subject Name: Theory of Computation Subject Code: 2160704
Academic Year: 2018-19 Semester: 6
Date: 9-1-2019
Sr.
Name of Question Remark
No.
01 Define sets, relations and functions with example.
Subject In charge
Laxmi Institute of Technology, Sarigam
Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad
ASSIGNMENT - 2
Department: Computer Science and Engineering
Name of Subject In charge: Farhin Mansur
Subject Name: Theory of Computation Subject Code: 2160704
Academic Year: 2018-19 Semester: 6
Date: 23-1-2019
Sr.
Name of Question Remark
No.
01 Define regular languages and regular expression with examples.
Subject In charge
Laxmi Institute of Technology, Sarigam
Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad
Question Bank
Department: Computer Science and Engineering
Name of Subject In charge: Farhin Mansur
Subject Name: Theory of Computation Subject Code: 2160704
Academic Year: 2018-19 Semester: 6
20. Convert the CFG, G ({S,A,B},{a,b},P , S) to CNF , where P is as follows S --> aAbB A -->
Ab | b B --> Ba | a
21. Consider following grammar: A1B-->S 0A | Λ-->A 0B | 1B | Λ-->B Give leftmost and
rightmost derivations of the string 00101. Also draw the parse tree corresponding to this
string.
22. Define CFG. When is a CFG called an ‘ambiguous CFG’?
23. Consider following grammar: ASB | Λ-->S aAS | a-->A SbS | A | bb-->B i. Eliminate
useless symbols, if any. ii. Eliminate Λ productions.
24. Given the Context Free Grammar G, find a CFG G’ in Chomsky Normal Form generating
L(G) – { }
1. S → aY | Ybb | Y X → /\ | a Y → aXY | bb | XXa
2. S → AA A → B | BB B → abB | b | bb
25. Show that the CFG with productions a | Sa | bSS | SSb | SbS→S is ambiguous.
26. Explain Chomsky Hierarchy.
27. Given the context-free grammar G, find a CFG G’ in Chomsky Normal Form. AaA | CA |
BaB→G : S→ aaBa | CDA | aa | DCA → bB | bAB | bb | aS B→ Ca | bC | DC bD | ɛ
D→ ɛ represents null.
28. Define Context Free Grammar. Find context-free grammar for the language: L = {ai bj | i < 2j}
29. Explain Union Rule and Concatenation Rule for Context-Free Grammar.
30. Let G be the grammar aB | bA→S a | aS | bAA→A b | bS | aBB→B For string
aaabbabbba, find Left most derivation and Right most derivation.
31. Define Context-Sensitive Grammar. Write a CSG for {an b n c n | n ≥ 1}.
32. Define Context-Sensitive Grammar. What is the language of following context-sensitive
grammar? aTb | abS aaTb | ac.aT
33. What is CNF? Convert the following CFG into CNF. S → ASA | aB, A → B | S, B → b | ε
34. For the following CFG, Find Chomsky normal form S->AACD A->aAb|ᴧ C-> aC|a D-
>aDa|bDb|ᴧ
35. For the following CFG, Find Chomsky normal form S->AaA|CA|BbB A->aaBa|CDA|aa|DC
B->bB|bAB|bb|aS C->Ca|bC|D D->bD|ᴧ
36. Define Context Free Grammar. Design a CFG for the following language L = {an b n | n >0}.
Laxmi Institute of Technology, Sarigam
Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad
37. Prove that the following language is ambiguous and convert into unambiguous E → E + E | E
* E | id
38. Convert the following language in Chomsky normal form. S→ASB | SAB A→ BC B→ bB | c
C→e
39. Define Context Free Grammar. Design a CFG for the language L = { ai b j c k | i ≠ j + k }
40. Give CFG equivalent to regular expression (011 + 1)* (01)*
41. Define Context Free Grammar(CFG). Design CFG for Generating Following Language: (1)
For Balanced Parenthesis (2) Set of even length strings in {a, b, c, d}* with two middle
symbol equal.
42. Design an ambiguous grammar for if-then-else statement that also generates if-then statement.
Re-write an equivalent unambiguous grammar. Prove that Grammar is Unambiguous by
tracing “ic1tic2taea”.
43. Given the Context Free Grammar G, find a CFG G’ in Chomsky Normal Form generating
L(G) – { } S → SS | A | B A → SS | AS | a B → /\
44. Generate the Context-Free Grammars that give the following languages. (i) {w | w contains at
least three 1s} (ii) {w | w starts and ends with the same symbol}
45. For given CFG G, find Chomsky normal form: G has productions: S -> AaA|CA|BaB A->
aaBa|CDA|aa|DC B->bB|bAB|bb|aS C-> Ca|bC|D D->bD|Λ
46. Given the CFG G, find a CFG G’ in Chomsky Normal form generating L(G) – { Λ} S→ A | B
| C A aAa | B B bB | bb C aCaa | D D baD | abD | aa
47. Define CFG and Design a CFG for the following language. L = { x ∈ {0,1}* | n0(x) ≠ n1(x) }
48. Differentiate Regular Grammars and Context Sensitive Grammars.
49. find an equivalent unambiguous grammar for following: S→ A|B A→ aAb|ab B →abB|Ʌ
50. Find context free grammar generating following language {ai bj c k | i = j or i = k}
51. Design a CFG for the following language. L = { 0i 1j 0k / j > i + k }
52. For the following CFG’s, describe the language it accepts. 1. S→ SS | XaXaX | ^ X → bX | ^
2. S→ aM | bS M → aF | bS F→ aF | bF | ^ 3. S → aS | bS | a | b | ^
53. Draw the PDA for the following language L = {ai bj c k | i = j+k}
54. Design a PDA, M to accept L = { an b 2n | n ≥ 1 }
55. For the language L = { xcxr {a,b}* } design a PDA(Push Down| x Automata).
56. Write Short note on Universal Turing Machine.
Laxmi Institute of Technology, Sarigam
Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad
57. Define a Turing Machine. Design a Turing machine for deleting nth symbol from a string w
from the alphabet ∑ = {0,1}.
58. Give definition of Turing Machine. What do you mean by an instantaneous description of a
Turing Machine?
59. Design a Turing machine for the language over {0,1} containing strings with equal number of
0’s and 1’s.
60. Write a Turing Machine to copy strings.
61. Draw a Turing Machine(TM) to accept Even and odd Palindromes over {a,b}.
62. Write Short note on Church-Turing Thesis.
63. Prove that following add(x,y) = x+y is primitive recursive function.
64. Draw a transition diagram for a Turing machine accepting the following language. { an bn cn |
n≥0}
65. Define functions by Primitive Recursion. Show that the function f(x, y) = x + y is primitive
recursive.
66. Describe recursive languages and recursively enumerable languages.
Laxmi Institute of Technology, Sarigam
Approved by AICTE, New Delhi; Affiliated to Gujarat Technological University, Ahmedabad
Academic Year 2018-19
Centre Code: 086 Examination : Mid Semester Exam-1
Branch: CSE Semester: 6 Sub Code: 2160704
Sub: Theory of Computation Date: 31-1-2019 Time:9 am to 10 am Marks: 20
Note: Attempt any four.
Q. 1 i. Design regular expression for the language with Σ={0,1} such that third character from 1
right end of the string is always 0.
ii. List out any two applications of DFA. 1
iii. Define dead end state. 1
iv. Draw DFA for the language which does not contain substring 00 over Σ={0,1}. 2
Q. 2 i. Prove that 1+3+5+…+ (2n-1) = n2 for n≥1 using principle of mathematical induction. 3
ii. Find Reflexive, Symmetric and Transitive closure of the relation R={ (a,a), (b,b), (a,b), 2
(b,a) }
Q. 3 Let M1 and M2 be the finite automata in figure below for the language L1 and L2 5
respectively
Q.1 (a) Define relation. Define reflexive and transitive relation. A binary relation R on 07
NxN is defined as (a,b)R(c,d) if a ≤ c or b ≤ d. Prove that R is reflexive but not
transitive.
(b) Define language. 07
Draw Deterministic Finite Automata for the following languages
i) L1 = { x ε (0,1)* | x contains 110111}
ii) L2 = { x ε (0,1)* | x contains odd number of zero and even number of 1}
iii) L3 = { x ε (0,1)* | x do not contains 110 }
Q.2 (a) Define mathematical induction. 02
Prove that if 0 < a < 1 then (1-a)n ≥ 1 – na. 05
(b) Define NFA and NFA-Λ. Convert the following NFA to DFA 07
OR
(b) Using proof by contradiction, prove √3 is Not a rational number. 07
Q.3 (a) Define Context Sensitive Grammar. Design a CSG for the following language 07
L = {anbncn | n > 0}.
(b) Prove that the following language is ambiguous and convert into unambiguous 07
S→S+S|S*S|a
OR
Q.3 (a) Minimize the following FSM 07
1
(b) Define Context Free Grammar. Design a CFG for the following language. 07
L = { x ε (0,1)* | n0(x) = n1(x)}
Q.4 (a) Define PDA. Draw a PDA for the complement of the following language 07
L = {wwR | w ε (0,1)*}
(b) Write regular expression for the following languages 07
i) L1 = {x ε (0,1)* | x do not ends with 11}
ii) L2 = {x ε (0,1)* | x contains both 101 and 110}
OR
Q.4 (a) Prove that any Regular Language can be accepted by FA. 07
*************
2
Seat No.: ________ Enrolment No.___________
S -> S + S | S * S | a | b
Write the unambiguous CFG based on precedence rules for the above grammar.
Derive the parse tree for expression (a + a)*b from the unambiguous grammar.
Q.3 (a) Let A = {1, 2, 3, 4, 5, 6} and R be a relation on A such that aRb iff a is a multiple of b. 07
Write R. Check if the relation is i) Reflexive ii) Symmetric iii) Asymmetric
iv) Transitive
(b) There are 2 languages over ∑ = {a , b} 07
1
Q.4 (a) Given a CFG , G =( {S,A,B},{0,1},P,S) with P as follows 07
S --> 0B| 1A A --> 0S|1AA|0 B --> 1S| 0BB | 1
Design a PDA M corresponding to CFG, G. Show that the string 0001101110
belongs to CFL , L(G)
(b) Design a PDA, M to accept L = { an b2n | n ≥ 1 } 07
OR
Q.4 (a) Design a FA for the regular expression (0 + 1)(01)*(011)* 07
(b) Write a regular expression for language L over {0,1} such that every string in L 07
i) Begins with 00 and ends with 11.
ii) Contains alternate 0 and 1.
Q.5 (a) Draw a transition diagram for a Turing machine accepting the following 07
language. { an bn cn | n ≥ 0 }
(b) Explain Universal Turing machine with the help of an example 07
OR
Q.5 (a) Define functions by Primitive Recursion. Show that the function f(x, y) = x + y is 07
primitive recursive.
(b) Prove Kleene’s Theorem (Part I): Any Regular Language can be accepted by a 07
Finite Automaton (FA).
*************
2
Seat No.: ________ Enrolment No.___________
MARKS
Q.1 Answer the following questions:
1 Define onto and one-to-one functions. 02
2 Give recursive definition of a tree. 03
3 Define reflexivity, symmetry, and transitivity properties of relations. 03
4 Consider the relation R = {(1,2), (1,1), (2,1), (2,2), (3,2), (3,3)} defined 03
over {1, 2, 3}. Is it reflexive? Symmetric? Transitive? Justify each of
your answers.
5 Draw truth table for following logic formula: P (¬P V ¬Q). Is it a 03
tautology? A contradiction? Or neither? Justify your answer.
Q.3 (a) Explain ‘finite state machines with outputs’. Discriminate between 03
Mealy and Moore machines.
(b) Convert the Moore machine shown in Fig. 2 into an equivalent Mealy 04
machine.
(c) Use Pumping Lemma to show that L = {x Є {0,1}* | x is a palindrome} 07
is not a regular language.
OR
Q.3 (a) Give recursive definition of regular expressions. State the hierarchy of 03
the operators used in regular expressions.
(b) Using constructive approach determine NFA- Λ for the regular 04
expression (0 + 1)*1(0 + 1).
(c) Fig. 3 shows two DFAs M1 and M2, to accept languages L1 and L2, 07
respectively. Determine DFAs to recognize L1 U L2.
1
Give formal definition of PDA. Give mathematical description of
Q.4 (a) ‘acceptance of a string by a PDA by empty stack’. 03
(b) Give the recursive definition of the iterated derivation (i.e., derivation 04
in zero or more steps), denoted as =>̽. Give mathematical description of
the language of a CFG.
**********
2
Note: In Fig.3 for Q:3 (c) consider transition from A -> B having symbol 0.