
Practice Problems
1. Assume that you have an algorithm ALGS such that ALGS takes as input a
Boolean Expression E(x1, … , xn) and reports whether or not there is a
SATISFYING assignment for E. Show that using ALGS, you can build and
algorithm ALGF which takes as input a Boolean Expression E(x1, … , xn)
and either reports that E is NOT satisfiable or returns a satisfying assignment
for E. Further show that if ALGS runs in polynomial time in n (the number
of variables) that ALGF will also run in polynomial time in the number of
variables.
2. Assume that you have an algorithm H that takes as input a graph G and
outputs YES if G has a HAMILTONIAN cycle and outputs NO if G does
not have a Hamiltonian cycle. Show how to construct an algorithm F so that
when F is given G, either F reports that G has no Hamiltonian cycle, or F
outputs a Hamiltonian cycle for G. Show that if H runs in polynomial time
in n (the number of vertices in G) then F will also run in polynomial time in
n.
3. Assume that you have an algorithm HAM() such that HAM(G) takes as
input a graph G, and outputs YES iff G has a Hamiltonian path and NO
otherwise. Construct an algorithm HE() such that HE(G, v1, v2) takes as
input a graph G and two vertices of G: v1and v2, and outputs YES iff there is
a Hamiltonian path in G beginning at vertex v1, and terminating at vertex v2,
and outputs NO otherwise. Show that if HAM() runs in time polynomial in
n (the number of vertices of G), that HE() will also run in time polynomial in
n.