Test Exam in4301 Advanced Algorithms

176 downloads 186 Views 212KB Size Report
Test Exam in4301 Advanced Algorithms ... Advanced Algorithms, IN4301 ... Give an example of how to construct such a search tree for this problem, and explain ...
TECHNISCHE UNIVERSITEIT DELFT Faculteit Elektrotechniek, Wiskunde en Informatica

Test Exam in4301 Advanced Algorithms January 2010

• Use a separate sheet for each question. • This is an closed book examination with 6 questions worth of 99 points in total. • Your mark for this exam will be the number of points divided by 10. • If you have at least a 5.0 for both this exam and the practical work, your final mark for this course is the average of both. • Use of book, readers, notes, and slides is not allowed. • Use of (graphical) calculators is not permitted. • Specify your name, student number and degree program, and indicate the total number of submitted pages on the first page. • Write clearly, use correct English, and avoid verbose explanations. Giving irrelevant information may lead to a reduction in your score. • This exam covers Chapters 10 and 11 of Kleinberg, J. and Tardos, E. (2005). Algorithm Design, all information on the slides of the course, and the papers as described in the study guide. • The total number of pages of this exam is 6 (excluding this front page).

Advanced Algorithms, IN4301

page 1 of 6

June 2009

1. Consider the problem of placing a minimum number of broadcasting stations in a communication network of cities in such a way that each city either has a broadcasting station or is directly connected to a city with a broadcasting station. This problem can be modeled as the problem of finding a dominating set of minimum size in a graph G. (a) (3 points) Give the definition of a dominating set S in a graph G = (V, E). Solution: A set S ⊆ V is a dominating set in a graph if each vertex v ∈ V is either in S or has a neighbor in S. (b) (6 points) To solve this problem we could try to apply the technique of pruning the search tree. Give an example of how to construct such a search tree for this problem, and explain how to compute the run-time of such a suggestion. Solution: For example, branch on the selection of a vertex v to be in the dominating set. This results in two sub-problems. Either put v in S and then remove v, and all vertices that are dominated and whose neighbors are also all dominated, or do not put v in S. This gives us sub-probems of a smaller size (e.g., size n − 1). The run time is then defined by a recurrence relation, for example T (n) = T (n − 1) + T (n − 1). The solution to this recurrence gives an upper bound on the run time. (In this case O(2n ), which is not very good.) (c) (6 points) In case G is a tree, we can efficiently solve this problem with a dynamic programming approach. Describe the main steps of this approach, illustrated by an example (preferably for the dominating set problem). Solution: The main steps of a dynamic programming approach are: 1. Give a recursive definition of the problem, e.g., for this problem we define two functions to call recursively for a sub-tree with root u: • OP Tin (u) denotes the minimum dominating set including u, and • OP Tout (u) denotes the minimum dominating set where u is not in the dominating set. Each of these functions is defined as follows: P • OP Tin (u) = 1 + v∈child(u) min {OP Tin (v), OP Tout (v)} n o P • OP Tout (u) = minv∈child(u) OP Tin (v) + w∈child(u),w6=v min {OP Tin (w), OP Tout (w)} In the above we take min(∅) = ∞. The answer is then given by min {OP Tin (r), OP Tout (r)}. 2. Implement this iteratively by storing the values to solutions to the subproblems in an array, starting with the leaves (i.e., visiting vertices in post-order), For example, in the above case we need two arrays of size n, one to store the optimal value for each function.

Advanced Algorithms, IN4301

page 2 of 6

June 2009

(d) (4 points) When G is not a tree, but looks a bit like a tree, a similar method based on dynamic programming can be used using a tree decomposition of G. Give a precise definition of a tree decomposition of a graph G. Solution: G = (V, E) can be modeled as a tree by a tree decomposition (T, {Vt }), which is defined as follows: • Every node in V belongs to at least one set Vt . • For every edge in E there is a set Vt that contains both end points. • For every three nodes t1 , t2 , t3 such that t2 lies on the path from t1 to t3 , it holds that if a node v belongs to both Vt1 and Vt3 , it also belongs to Vt3 . (e) (6 points) Often it is useful to apply kernelization to solve this problem. Give a precise definition of when a decision problem with input (I, k) is kernelizable, where I is the problem instance and k is a parameter. Also, give an example of a rule that can contribute to obtaining a kernel of the minimum dominating set problem. Solution: A decision problem with input (I,k) is kernelizable if every such input can be reduced to an instance (I’, k’) s.t.: 1. k’ ≤ k 2. |I’| is smaller than g(k) for some function g only depending on k 3. (I’, k’) has a solution if and only if (I, k) has one, and 4. the reduction from (I, k) to (I’, k’) must be computable in polynomial time. For the dominating set problem, examples of rules to arrive at an instance I 0 of smaller size are the following: 1) include all isolated vertices in S, or 2) for each vertex v of degree 1 put its neighbor in the dominating set S, or 3) one of the more complex rules (DS1 and DS2) from Huffner et al. 2. In the knapsack problem, we have a knapsack of volume V and a collection of n objects whose volumes are v1 . . . vn and whose costs are c1 , ..., cn . Your task is to select items to pack in your knapsack so that the total cost of those items is maximized, subject to the constraint that the total volume of the selected items does not exceed V . (a) (4 points) It seems reasonable in selecting items to base the selection upon the ratio to volume. Specify a greedy algorithm based on this principle Solution: begin Let S = ∅; let R = 0; while R < V select an item j from the remaining items such that

cj vj

is maximal;

ci vi

of cost

Advanced Algorithms, IN4301

page 3 of 6

June 2009

if R + vj ≤ V then add j to S, add vj to R and remove j from the remaining items; return S end (b) (5 points) Show by giving an example with 3 items that your greedy algorithm does not always provide an optimal solution to the Knapsack problem. Solution: Let the capacity of the knapsack be 4 and consider three items, item a with volume 3 and cost 5 (ratio 1.666); items b and c both with volume 2 and cost 3 (ratio 1.5). The greedy solution would reach for item a because it has the highest ratio of cost to volume. Having placed item a, there would be no space remaining for any more items, so the total cost we would carry off would be 5. This is non-optimal since we would be better off taking items b and c and make off with a total value of 3 + 3 = 6. (c) (5 points) Present the definition of an approximation ratio to measure the approximation quality of the greedy algorithm. Solution: The approximation ratio of an approximation algorithm A w.r.t. a minimization or maximization problem P is defined as follows: Let I be an instance of P and A(I) the value returned by the algorithm A for I; 1. if P is a minimization problem and OP T (I) is the minimum value obtainable for instance I then RA (I) = A(I)/OP T (I) 2. if P is a maximization problem and OP T (I) is the maximum value obtainable for instance I then RA (I) = OP T (I)/A(I) Then the approximation ratio rA is the smallest value such that rA ≥ RA (I) for all instances I of P . (d) (2 points) Explain what the difference is between the approximation ratio rA of an approximation algorithm A for P and the approximation threshold r of P . (e) (3 points) What is a tight example for an approximation algorithm with a given approximation ratio rA ? Solution: A tight example for an approximation algorithm A with approximation ratio rA is an instance I such that RA (I) = A(I)/OP T (I) = rA (for a minimization problem). (f) (6 points) Discuss the gap introducing reduction technique presented in class for showing that a given problem cannot be approximated within a certain ratio r (