assignment5_sol - CSIS0250B Design and Analysis of...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CSIS0250B Design and Analysis of Algorithms Sample Solution to Assignment Five Questions 1 - 5 carry 20 marks each. 1. The input to the Clique-3 problem consists of a graph G and a positive integer b where the degree of G is bounded by 3. CLIQUE-3 is the problem of determining whether G has a clique of size b . Note that the size of the biggest clique in G is at most 4 because every vertex in G is adjacent to at most 3 other vertices. (a) On input a graph G and a positive integer b , Step 1: return false if b > 4; Step 2: guess a set S of b vertices in G ; Step 3: return true if there is an edge in G between every pair of vertices in S . Otherwise, return false. Step 1 takes O (1) time, Step 2 takes O ( n ) time, while Step 3 takes O ( b 2 ) = O (1) time when b 4. So CLIQUE-3 NP. (b) The direction of reduction is incorrect. To show that CLIQUE-3 is NP-complete, one needs to prove CLIQUE P CLIQUE-3 instead. (c) The reduction that says C is a vertex cover of G if and only if V C is a clique of G does not hold. Cosider a graph G with 4 vertices { a, b, c, d } and 3 edges { ( a, b ) , ( a, c ) , ( a, d ) } . { a } is a vertex cover of size 1, but { b, c, d } are not connected and do not form a clique of size 3. (d) The following procedure determines whether G has a clique of size b . Step 1: return false if b > 4; Step 2: enumerate all subsets S of b vertices in G ; Step 3: return true if there is an S that forms a clique of size b ; otherwise, return false. There are O ( | V | b ) subsets of b vertices in G . Checking whether S forms a clique of size b takes O ( b 2 ) = O (1) time for b 4. So the time taken by the algorithm is O ( | V | b ) = O ( | V | 4 ). 2. Let P be the algorithm that can determine whether a boolean formula f is satisfiable or not in polynomial time. That is, P ( f ) is true if f is satisfiable, and P ( f ) is false otherwise. Given a boolean formula f with n variables x 1 , x 2 , · · · , x n , the following algorithm compute a satisfying truth assignment A [1 ..n ] for x i s. If P(f) is false then report "f is not satisfiable." else g = f; for each variable x_i in f do if P(x_i and g) = true then A[i] = true; g = x_i and g; /* include a clause containing literal x_i to g */ else A[i] = false; g = not(x_i) and g; /* include a clause containing literal not(x_i) to g */ 1
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
end if end for end if The time taken by the algorithm is O ( n · T ( g )) where g contains n more clauses than f , and T ( g ) is the time taken by P on input g . So T ( g ) is polynomial in terms of the size of the input f .
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern