Docstoc

java progarma

Document Sample
java progarma Powered By Docstoc
					                               Solutions for Homework 2
                                           MA 522 Fall 2008

1.
(a) Show that an otherwise polynomial-time algorithm that makes at most a constant
number of calls to polynomial-time subroutines runs in polynomial time;

    Proof: Assume that for 1 ≤ i ≤ c our algorithm calls a subroutine Si with input xi
of binary length mi . Assume that Si performs at most nei binary operations on inputs of
length n, where ei doesn’t depend on n. Let ne0 is an upper bound for the running time
for our algorithm on input of length n – without the subroutine calls. Then

                                         ne0 + me1 + . . . + mec
                                                1             c

is the total running time of the algorithm (with subroutine calls) on an input of length n.
Here c, e0 , . . . , ec do not depend on n. By induction we will prove that the input size mi
of Si is at most nfi for fi ≤ i−1 ej – not depending on n. For i = 1 we have f1 ≤ e0 ,
                                     j=0
which proves the base case. Assume that the mi−1 ≤ nfi−1 . Then the output size of Si−1 is
at most (nfi−1 )ei−1 , therefore the input size of Si is at most (nfi−1 )ei−1 = nfi−1 (ei−1 ) . (We can
assume without loss of generality that the output of Si−1 is the input of Si .) Therefore,
fi ≤ i−1 ej , which proves the inductive step. Thus we have that the total running time
        j=0
is at most
                                       e1             ec           c      c
                             ne0 + nf1 + . . . + nfc     ∈ O(n(maxj=0 ej ) )
and the exponent of the right hand side does not depend on n.

    (b) Show that a polynomial number of calls to polynomial time subroutines may result
in an exponential-time algorithm.

    Proof: Here is an example for such algorithm: Each subroutine Si has running time at
most ne for inputs of size n, but the input size of Si is mi := 2i−1 n. For example Si squares
its input x in linear time. Then Sn has input size 2n−1 n, so its running time is linear in
2n−1 n, which is not polynomial time.


2. Let
                FACTORING = {(n, k) : n has some factor d with 1 < d < k}.
(a) Show that FACTORING ∈ NP;
Proof: The witness is (n, k, d), and the verifying algorithm checks whether 1 < d < k and
d|n, which is clearly polynomial time.

    (b) Show that FACTORING ∈ co-NP (using that PRIMES ∈ NP).
Proof: Witness: (n, k, p1 , . . . , pr , wit(p1 ), . . . , wit(pr )) where (pi , wit(pi )) is the NP-witness
for pi ∈ PRIMES.
The verifying algorithm checks the following things:

                                                     1
             r
  1. n =     i=1   pi

  2. 1 < k < pi for all 1 ≤ i ≤ r

  3. verify that (pi , wit(pi )) satisfies the PRIMES certificate

Note that the size of the certificate is polynomial in log(n), since n has at most log(n) prime
factors of size at most log(n), and for each prime of size at most log(n), its PRIMES witness
has also polynomial size in log(n).

3.
(a) Prove that if NP = co-NP, then P = NP.
Proof: Assume that P=NP. Then the polynomial time algorithms for an NP language L
can be used to decide whether x ∈ L, thus P=co-NP, so NP=co-NP, a contradiction.

    (b) Prove that if FACTORING is NP-complete then NP = co-NP.
Proof: If FACTORING is NP-complete then for all L ∈ NP L ≤P FACTORING. Since
FACTORING is in co-NP, it implies that all L ∈ NP L ∈ co-NP, i.e.NP ⊆ co-NP. Now
                       ¯
let L ∈ co-NP. Then L ∈ NP ⊆ co-NP, thus L ∈ NP, i.e. co-NP ⊆ NP. This proves that
NP=co-NP.

4. The subgraph-isomorphism problem takes two graphs G1 and G2 and asks whether G1
is isomorphic to a subgraph of G2 . (Two graphs are isomorphic, if there is a permutation
of the verteces which transform one graph into the other, preserving the edges). Prove
that the subgraph isomorphism problem is NP-complete, using NP-complete problems
discussed in class.
Proof: First we prove that the subgraph-isomorphism problem is in NP. The certificate
is (G1 = (V1 , E1 ), G2 = (V2 , E2 ), φ : V1 → V2 ). The verifying algorithm checks if φ isa one-
to-one function, and for all u, v ∈ V1 whether (u, v) ∈ E1 if and only if (φ(u), φ(v)) ∈ E2 .
Secondly, we prove that CLIQUE ≤P SUBGRAPH ISOMORPHISM. Let (G = (V, E), k) be
an input instance for CLIQUE. Define G1 to be the complete graph on k vertices, and G2
to be the grapgh G. Then (G1 , G2 ) ∈ SUBGRAPH ISOMORPHISM if and only if (G, k) ∈
CLIQUE.




                                               2

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:5
posted:2/13/2010
language:English
pages:2
Description: hi it is best describe online class.