TDDD65 Introduction to the Theory of Computation Example Examination 1

advertisement
2012-09-28
Linköpings Tekniska Högskola
Institutionen för Datavetenskap
Gustav Nordh
TDDD65 Introduction to the Theory of Computation
Example Examination 1
Material allowed:
Questions:
Grading
Results
An English dictionary (to any language) is allowed. Other material (like books,
lecture notes, own notes etc. ) and electronic equipment (computers, calculators,
mobile phones etc.) is not allowed.
Gustav Nordh, 282694 (or 0739 871855) will appear in the examination room
around XX.XX
There are 7 problems giving max 30 points. To pass you need 15 points. The
lower bounds of points for the grades 3,4,5 are as follows: 3:15, 4:20, 5:25.
as soon as the exams are graded there will be a meeting (called in Swedish
“tentavisning”) where you can look at your graded exam and discuss the result
with the examiner. The announcement will be posted at the course homepage
approx. one week after the exam.
Please observe the following:
• Solutions to different problems should be placed one-sided on separate page(s).
• Justify properly your answers: missing or insufficient explanations will result in reduction of
points.
• Be sure that your answers are readable.
• Leave space for comments.
Good luck!
1
1.
(3 p)
(a) State the Church-Turing thesis.
(1)
(b) Do you believe that the Church-Turing thesis holds? Write a short argument (at most
100 words) supporting your point of view.
(2)
2. The language L over the alphabet Σ = {0, 1} consists of all strings over Σ ending with 00 or
11. So for example, 01011 ∈ L but 010 ∈
/ L.
(6 p)
(a) Give a regular expression defining L.
(2)
(b) Draw the transition graph of a 4-state NFA N that recognize L.
(2)
(c) Transform N into an equivalent DFA using the subset construction.
(2)
3. Consider the following language
(5 p)
L = {ai bj cj di | i, j ≥ 1} ∪ {ai bi cj dj | i, j ≥ 1}.
(a) Prove that L is context-free by giving a CFG that generate L.
(4)
(b) Prove that your grammar is ambiguous.
(1)
4. Consider the language L = {w ∈ {0, 1}∗ | #0(w) ≤ #1(w)} where #0(w) denotes the
number of 0’s in w and #1(w) denotes the number of 1’s in w. So for example, 10011 ∈ L
since #0(10011) = 2 ≤ 3 = #1(10011), but 1010001 ∈
/ L since #0(1010001) = 4 > 3 =
#1(1010001).
(4 p)
Use the pumping lemma to prove that L is nonregular.
5. Consider the languages A, B, and C, where A the union of two regular languages, B is not
Turing recognizable, and C is Turing recognizable but not decidable. Given the following
mapping reductions:
(3 p)
• F ≤m A,
• B ≤m D,
• E ≤m C, and
• A ≤m E,
what can you conclude about the decidability of the languages D, E, and F ?
6. Recall that kSAT is the problem of checking the satisfiability of kCNF-formulas, i.e., checking
the satisfiability of conjunctions of clauses with k literals. MONOTONE-SAT is the problem
of checking satisfiability of CNF-formulas where each clause consists of only positive literals
(i.e., unnegated variables) or only negative literals (i.e., negated variables).
(5 p)
For example,
(x1 ∨ x2 ∨ x3 ) ∧ (x1 ∨ x2 ∨ x4 ) ∧ (x1 ∨ x2 )
is a satisfiable MONOTONE-SAT-formula.
(a) Briefly explain why MONOTONE-SAT is in NP.
(1)
(b) Prove that MONOTONE-SAT is NP-complete by giving a reduction from 3SAT. (Hint:
formulas of the form (xi ∨ xj ) ∧ (xi ∨ xj ) might be useful in your reduction.)
(4)
2
7. Consider the following two algorithms where the input is an undirected graph and we
define the size of the input to be the number of vertices of the graph.
TRIANGLE: This algorithm outputs true if the graph contains a triangle (i.e., a set
of 3 distinct vertices that are adjacent to each other) and false otherwise.
For each set of 3 distinct vertices from the graph, check whether the set form a triangle, and
in that case output true. If none of the 3-element sets form a triangle, then output false.
3COL: This algorithm outputs true if the graph can be properly colored by 3 colors
(i.e., if every vertex can be assigned a color (say Red, Blue, or Green) such that no two
adjacent vertices get the same color) and false otherwise.
For each possible assignment of colors (i.e., Red, Blue, or Green) to all the vertices in the
graph, check whether the graph is properly 3 colored, and in that case output true. If none
of the assignments is a proper 3 coloring, then output false.
Analyze the worst-case time complexity of these algorithms and explicitly state whether they run in polynomial time or exponential time.
3
(4 p)
Download