Odds and Ends - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Odds and Ends

Description:

Odds and Ends. HP p HC (again) Turing reductions ... Impose an arbitrary ordering on the items. V(i,w) is the value of this set of items ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 21
Provided by: erict9
Learn more at: http://www.cse.msu.edu
Category:
Tags: ends | odds | oddson

less

Transcript and Presenter's Notes

Title: Odds and Ends


1
Odds and Ends
  • HP p HC (again)
  • Turing reductions
  • Strong NP-completeness versus Weak
    NP-completeness
  • Vertex Cover to Hamiltonian Cycle

2
Example HP p HC
  • Hamiltonian Path
  • Input Undirected Graph G (V,E)
  • Y/N Question Does G contain a Hamiltonian Path?
  • Hamiltonian Cycle
  • Input Undirected Graph G (V,E)
  • Y/N Question Does G contain a Hamiltonian Cycle?

3
Specification of R(x)
  • Consider any undirected graph G (V,E) as input
    x
  • R(x) will be a graph G (V, E) where
  • V V union v where v is not in V
  • E E union (v,w) w in V
  • Argument that R(x) has polynomial size
  • We add exactly 1 node and V edges.

4
x is yes ? R(x) is yes
  • Suppose graph G has a Hamiltonian Path
  • Let this path be v1, v2, , vn
  • We now argue that v1, v2, , vn, v is a
    Hamiltonian Cycle in G
  • First, all nodes in V are included exactly once
    above or else v1, v2, , vn would not be a HP in
    G
  • Since G has all the edges that G has, (vi,vi1)
    is an edge in E for 1 i n-1
  • Finally, since E contains edge (v,w) for all w
    in V, it must be the case that E contains edges
    (vn, v) and (v,v1).

5
R(x) is yes ? x is yes
  • Suppose graph G has a Hamiltonian Cycle
  • Let this cycle be v1, v2, , vn, v
  • We now argue that v1, v2, , vn is a Hamiltonian
    Path in G
  • First, all nodes in V are included exactly once
    above or else v1, v2, , vn, v would not be a HC
    in G
  • Since the only extra edges in E compared to E
    are edges involving node v, it must be the case
    that E contains edge (vi,vi1) for 1 i n-1

6
Turing Reducibility
  • Consider the following alternate reduction.
  • Given graph G, output Q(n2) graphs Gv,w
    (V,Ev,w) where
  • Ev,w E union (v,w) where v,w are nodes in V
  • This is not a polynomial-time reduction because
    we are outputting Q(n2) graphs.
  • However, this idea can be used to show that if HC
    can be solved in polynomial time, then HP can be
    solved in polynomial time.
  • Run each graph Gv,w through our procedure that
    solves HC.
  • If HC says yes for any one of these graphs,
    return yes.
  • Otherwise return no.
  • This more general reduction is often called a
    Turing reduction.
  • We allow ourselves to use the procedure that
    solves HC (or P2) a polynomial number of times
    rather than just once.

7
Number Problems
  • Problems where the inputs are numbers
  • Prime number problem
  • Input Integer n
  • Yes/No Question Is n prime?
  • Partition problem
  • Input Set S of n numbers s1, , sn
  • Yes/No Question Is there an S subset of S such
    that the sum of numbers in S the sum of
    numbers in S S.
  • What is the input size for these problems?

8
Knapsack Problem
  • 0-1 Knapsack optimization problem
  • Input
  • Capacity K
  • n items with weights wi and values vi
  • Yes/No Question
  • Find a set of items S such that
  • the sum of weights of items in S is at most K
  • the sum of values of items in S is maximized
  • We gave a dynamic programming solution for this
    problem
  • We showed that Partition p Knapsack on hw 8
  • Is this a contradiction?

9
Definining subproblems
  • Define P(i,w) to be the problem of choosing a set
    of objects from the first i objects that
    maximizes value subject to weight constraint of
    w.
  • Impose an arbitrary ordering on the items
  • V(i,w) is the value of this set of items
  • Original problem corresponds to V(n, K)

10
Recurrence Relation/Running Time
  • V(i,w) max (V(i-1,w-wi) vi, V(i-1, w))
  • A maximal solution for P(i,w) either
  • uses item i (first term in max)
  • or does NOT use item i (second term in max)
  • V(0,w) 0 (no items to choose from)
  • V(i,0) 0 (no weight allowed)
  • What is the running time of this solution?
  • Number of table entries
  • Time to fill each entry

11
Example
Items
wA 2 vA 40 wB 3 vB 50 wC 1 vC
100 wD 5 vD 95 wE 3 vE 30
Weight
12
Weak NP-completeness
  • An NP-complete problem is called weakly
    NP-complete if it has in its description one or
    more integer parameters and the corresponding
    problem where these parameters are represented in
    unary is in P.
  • An NP-complete problem is strongly NP-complete if
    the problem is still NP-complete even if integer
    parameters are encoded in unary

13
Vertex Cover to Ham Cycle
Edge Component For every edge in the Minimum
Vertex Cover problem, we create a component in
the Hamiltonian Cycle Problem
v
u
14
Observations.
u
v
u
v
u
v
v?
v?
u?
u?
v?
u?
There are only three possible ways that a cycle
can include all of the vertices in this
component. Key property If a path enters v (u),
it leaves on v (u)
15
Node Selection
u
v
All components that represent edges connected to
node u are strung together into a chain. If
there are V vertices, then we will have V of
these chains, all interwoven. Choosing a node u
corresponds to traversing such a chain
u?
v?
u
w
w?
u?
u
x
x?
u?
16
u
w
y
v
u?
w?
y?
v?
u
v
y
w
v
u
x
z
v?
u?
v
u
x
z
Vertex cover (v,u)
x?
u?
z?
v?
17
u
w
y
v
u?
w?
y?
v?
u
v
y
w
v
u
x
z
v?
u?
v
u
x
z
Vertex cover (v,w,x)
x?
u?
z?
v?
18
Tying the Chains Together
If we want to know if its possible to cover the
original graph using only k vertices, this would
be the same as seeing if we can include all of
the vertices using only k chains. How can we
include exactly k chains in the Hamiltonian Cycle
problem? We must add k extra vertices and
connect each of them to the beginning and end of
every chain. Since each vertex can only be
included once, this allows k chains in the final
cycle.
19
Beginning a Transform








20
The Final Transform for k1







Write a Comment
User Comments (0)
About PowerShow.com