Homework 7 Practice - Algorithm Design and Analysis | ECS 122A, Assignments of Computer Science

Material Type: Assignment; Professor: Bai; Class: Algorithm Design; Subject: Engineering Computer Science; University: University of California - Davis; Term: Spring 2009;

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-7bt
koofers-user-7bt 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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 < si1, 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=SAsuch that
X
xA
x=X
x¯
A
x.
Show that the SP problem is NP-complete by reducing from Subset-Sum problem.
1

Partial preview of the text

Download Homework 7 Practice - Algorithm Design and Analysis | ECS 122A and more Assignments Computer Science in PDF only on Docsity!

ECS122A: Algorithm Design and Analysis Due: 4:00pm, June 8, 2009 Homework Assignment #

  1. The bin packing decision problem is that given an unlimited number of bins, each of capacity 1, and n objects with sizes s 1 , s 2 ,... , sn, where 0 < si ≤ 1, do the objects fit in k bins? where k is 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 k is 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 S of numbers. The question is whether the numbers can be partitioned into two sets A and A¯ = S − A such that ∑

x∈A

x =

x∈ A¯

x.

Show that the SP problem is NP-complete by reducing from Subset-Sum problem.