
ECS122A: Algorithm Design and Analysis Due: 4:00pm, June 8, 2009
Homework Assignment #7
1. The bin packing decision problem is that given an unlimited number of bins, each of capacity 1,
and nobjects with sizes s1, s2,...,sn, where 0 < si≤1, do the ob jects fit in kbins? where kis
a given integer.
The bin packing optimization problem is to find the smallest number of bins into which the objects
can be packed.
Show that if the decision problem can be solved in polynomial time, then the optimization problem
can also be solved in polynomial time.
2. Show that if the hamiltonian cycle decision problem can be solved, then the problem of listing the
vertices of a hamiltonian cycle, in order is also solvable.
3. Suppose that we had a polynomial-time subprogram TSP to solve the traveling saleperson decision
problem (i.e., given a complete weighted graph and an integer k, it determines whether there is a
tour of total weight at most k.)
(a) Show how to use the TSP subprogram to determine the weight of an optimal tour in polynomial
time.
(b) Show how to use the TSP subprogram to find an optimal tour in polynomial time.
4. A graph G= (V, E ) is said to be k-colorable if there is a way to paint its vertices using k
different colors such that no adjacent vertices are painted the same color. When kis a number,
by k-COLOR we denote the decision problem of k-colorable graphs.
(a) Give an efficient algorithm to determine a 2-coloring of a graph if one exists.
(b) The 3-COLOR problem is NP-complete (You may assume this). Use this to prove that the
4-COLOR is NP-complete.
5. The Set-Partition (SP) problem takes as input a set Sof numbers. The question is whether
the numbers can be partitioned into two sets Aand ¯
A=S−Asuch that
X
x∈A
x=X
x∈¯
A
x.
Show that the SP problem is NP-complete by reducing from Subset-Sum problem.
1