2

Click here to load reader

Answers to Quiz 6 CIS 675 Algorithms - Syracuse …royer/09cis675/q6ans.pdf · Find: A pairwise disjoint subcollection fS 1,. . .,S ... Answers to Quiz 6 CIS 675 ^ Algorithms b.(1

Embed Size (px)

Citation preview

Page 1: Answers to Quiz 6 CIS 675 Algorithms - Syracuse …royer/09cis675/q6ans.pdf · Find: A pairwise disjoint subcollection fS 1,. . .,S ... Answers to Quiz 6 CIS 675 ^ Algorithms b.(1

Answers to Quiz 6 CIS 675 ^ Algorithms

Score Distribution Average≈ 16.57. Median = 17.5. For the histogram,fractional scores were rounded down.

0- 1: 0

2- 3:

4- 5:

6- 7:

8- 9: 8

10-11: 10 11 11

12-13: 12 12 12 13

14-15: 14 14 14 15 15 15 15 15 15 15 15 15 15

16-17: 16 16 16 16 16 16 16 16 16 17 17 17 17 17 17 17 17 17 17 17 17 17 17

18-19: 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 19 19 19 19 19 19 19 19 19 19 19

20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20

Problem 1. (6 points)Give the definition and an example/instance of each of the following:

a. a checking algorithm for a search problem

An answer to 1a. Definition: A checking algorithm for a search problemtakes I, an instance to the problem, and S, a possible solution to I, andtests if S really does solve I. Moreover, the algorithm runs in O(|I|k)for some k. Example: A checker for SAT would take a CNF formula φand a truth assignment to the variables and evaluate φ under that truthassignment to see if φ is true.

b. the zero-one equations problem

An answer to 1b. Definition: The problem of finding, for a matrix Aof 0’s and 1’s, a column vector ~x such that A~x = ~1. Example: Take

A =

[1 00 1

]which has ~x =

[11

]as a solution.

Problem 2. (4 points) Suppose:

ä Both P and Q are search problems and P E Q with f and h as thetwo polynomial-time computable functions associated with the re-duction.

ä AQ is a polynomial-time algorithm for Q. That is, given IQ, an in-stance of Q, Q finds a solution for IQ or else reports that there is nosolution for IQ; moreover, AQ on input IQ runs in O(|IQ|k) time forsome k > 0.

Give a polynomial-time algorithm for P. Be sure to explain why youralgorithm runs in polynomial-time.

An answer to 2. Here is the algorithm.input I, an instance of Presult← AQ( f (I))if result =“no answer” then return “no answer”else return h(result)

Since f , h, and AQ are poly-time computable (and since polytime func-tions are closed under composition) the above is also poly-time.

Problem 3. (10 points)This question concerns the following two search problems. (Definition 1on page 2 may be helpful here.)

3D-Matching.Given: Sets A, B, and C with |A| = |B| = |C| = n and T ⊆A× B× C.Find: M ⊆ T with |M| = n such that if (a, b, c) and (a′, b′, c′) aredistinct elements of M, then a 6= a′, b 6= b′, and c 6= c′.

Exact-Set-Cover.Given: S , a finite collection of finite sets. and K, a positive integer.Find: A pairwise disjoint subcollection { S1, . . . , SK } ⊆ S that cov-ers

⋃ S .

a. (1 point) Explain why Exact-Set-Cover is in NP.

An answer to 3a. Here is a checking algorithm for Exact-Set-Cover.input (S , K) and { S1, . . . , Sm })Check that m = K and Si ∩ Sj = ∅ for i 6= j.Check that

⋃ S =⋃m

i=1 Sireport whether all the checks were passed.

It is straightforward to show that the above is poly-time.

For parts b, c, and d, suppose (A, B, C, T) is an instance of 3D-Matching,where A, B, and C are pairwise disjoint. Let S = { { a, b, c } : (a, b, c) ∈ T }and K = |A|.

Page 1 of 2 December 15, 2009

Page 2: Answers to Quiz 6 CIS 675 Algorithms - Syracuse …royer/09cis675/q6ans.pdf · Find: A pairwise disjoint subcollection fS 1,. . .,S ... Answers to Quiz 6 CIS 675 ^ Algorithms b.(1

Answers to Quiz 6 CIS 675 ^ Algorithms

b. (1 point) Explain why (S , K) is an instance of Exact-Set-Cover.

An answer to 3b. S is a collection of sets and K is a positive integer.

c. (2 points) Suppose M is a solution to the 3D-Matching problem(A, B, C, T). Let S ′ = { { a, b, c } : (a, b, c) ∈ M }. Explain why S ′ isa solution to the Exact-Set-Cover problem (S , K).

An answer to 3c. By construction, |S ′| = n = K; and if { a, b, c } and{ a′, b′, c′ } are distinct elements of S ′ (and a, a′ ∈ A, b, b′ ∈ B, and c, c′ ∈C), then (a, b, c), (a′, b′, c′) ∈ M, and by the conditions on 3D-Matching,a 6= a′, b 6= b′, and c 6= c′ so { a, b, c } ∩ { a′, b′, c′ } = ∅ since A, B, and Care pairwise disjoint. Also since

⋃ S = A ∪ B ∪ C =⋃ S ′, S ′ is a cover.

Hence, S ′ is a solution to (S , K).

d. (2 points) Suppose { S1, . . . , SK } is a solution to the Exact-Set-Coverproblem (S , K). Let

M = { (a, b, c) : { a, b, c } = Si, a ∈ A, b ∈ B, c ∈ C, 1 ≤ i ≤ K }.Explain why M is a solution to the 3D-Matching problem (A, B, C, T).

An answer to 3d. Since K = |A| = |B| = |C|, M has the right numberto triples. Since the Si’s are pairwise disjoint, it follows that if (a, b, c)and (a′, b′, c′) are distinct elements of M, then a 6= a′, b 6= b′, and c 6= c′.Hence, M is a solution to (A, B, C, T).

e. (3 points) Show that 3D-Matching E Exact-Set-Cover. Be sure to:

(i) (1 point) say what the functions f and h are,(ii) (1 point) explain why if I is an instance of 3D-Matching and S is a

solution to f (I), then h(S) is a solution to I, and(iii) (1 point) explain why if I is an instance of 3D-Matching that has a

solution, then f (I) is an instance of Exact-Set-Cover that also has asolution.

You may assume that the sets A, B, and C in each instance of 3D-Matchingare pairwise disjoint.

An answer to 3e.(i) f (A, B, C, T) = (S = { { a, b, c } : (a, b, c) ∈ T }, K = |A|).

h(S ′) = { (a, b, c) : { a, b, c } ∈ S ′, a ∈ A, b ∈ B, c ∈ C }.(ii) See part d. (Yes, that is all you needed to say.)

(iii) See part c. (Yes, that is all you needed to say.)

f. (1 point) Suppose we know that 3D-Matching is NP-complete. Usingthe above (and maybe some Math Facts) explain why Exact-Set-Cover isalso NP-complete.

An answer to 3f. As 3D-Matching is NP-complete, every problem in NPreduces to it. By part e, 3D-Matching E Exact-Set-Cover. By Fact 1, Eis transitive. Hence, every problem in NP-reduces to Exact-Set-Cover.Therefore, by Definition 3a, Exact-Set-Cover is NP-hard. By part a,Exact-Set-Cover is in NP. Therefore, as Exact-Set-Cover is NP-hard andin NP, Exact-Set-Cover is NP-complete by Defintion 3b.

Some Reference Math Facts

Definition 1. Suppose { S1, . . . , Sm } is afinite collection of finite sets.

a.⋃{ S1, . . . , Sm } = S1 ∪ · · · ∪ Sm.

b. { S1, . . . , Sm } covers a set U when⋃{ S1, . . . , Sm } ⊇ U.

c. { S1, . . . , Sm } is a pairwise disjoint col-lection when Si ∩ Sj = ∅ for i 6= j.

Definition 2. For search problems P andQ, P E Q means that there are polynomial-time computable functions f and h suchthat

ä If I is an instance of P, then f (I) is aninstance of Q and if S is a solution of

f (I), then h(S) is a solution of I.

ä If I is an instance of P that has a solu-tion, then f (I) is an instance of Q thathas a solution.

Definition 3.

a. A is NP-hard means that B E A for ev-ery B in NP.

b. A is NP-complete means that A is both:(i) in NP and (ii) NP-hard.

Facts

1. E is transitive. That is, [A E B andB E C] implies that A E C.

2. If A is NP-hard and A E B, then B isNP-hard.

Page 2 of 2 December 15, 2009