Download ALGORITHMS - HOMEWORK 5 - SOLUTIONS 1. Consider the

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Factorization of polynomials over finite fields wikipedia , lookup

Algorithm wikipedia , lookup

Centrality wikipedia , lookup

Dynamic programming wikipedia , lookup

Transcript
MATH CAMP - ALGORITHMS - HOMEWORK 5 - SOLUTIONS
MICHELLE BODNAR
1. Consider the following closest-point algorithm for building an approximate traveling-salesman
tour whose cost function satisfies the triangle inequality. Begin with a trivial cycle consisting of
a single arbitrarily chosen vertex. At each step, identify the vertex u that is not on the cycle but
whose distance to any vertex on the cycle is minimum. Suppose that the vertex on the cycle that
is nearest u is vertex v. Extend the cycle to include u by inserting u just after v. Repeat until all
vertices are on the cycle. Prove that this algorithm is 2-approximate.
Suppose v is on our cycle and we are about to add vertex u because its distance to v is
smaller than the distance from any other vertex not on the cycle to any vertex on the cycle.
Let w be the vertex which comes after v on the cycle. Since the TSP satisfies the triangle inequality, c(w, u) ≤ c(w, v) + c(u, v). The net increase in cost by adding vertex u to the path is
c(v, u) + c(u, w) − c(v, w) ≤ c(v, u) + c(w, v) + c(u, v) − c(v, w) = 2c(v, u). Let xi be the distance from
the ith vertex added to the (i + 1)st vertex added. Then the total cost of the closest-point algorithm
is 2 ∑ni=1 xi , where the (n + 1)st vertex is understood to be the first vertex. The edges which we
add in the approximation algorithm turn out to form a minimum spanning tree, so the total cost
of the algorithm is twice the cost of a minimum spanning tree. In class we showed that the cost of
a minimum spanning tree is bounded above by the cost of an optimal tour. This implies that the
cost of our approximation algorithm is at most twice the cost of an optimal tour.
2. Suppose that the vertices for an instance of the traveling-salesman problem are points in the
plane and that the cost c(u, v) is the euclidean distance between points u and v. Show that an
optimal tour never crosses itself.
Suppose that the tour did cross itself. Then we would be in a setup which looks like the picture
drawn below:
Explicitly, there must exist vertices u, v, w, and z such that edge (u, v) crosses edge (w, z). In
the path given, we first follow the edge from z to w, then follow some unspecified path from w to
v, then follow the edge from v to u. Let path P denote the path obtained by following the original
tour up to z, going straight from z to v, following the original path from w to v in reverse (which
preserves cost), going straight from w to u, then following the original path from u back to the
start. We’ll prove that we incur a smaller total cost by taking path P .
We can imagine that there is some point c which corresponds to the intersection point of the
edges. Let c(x, y) be the distance between x and y. Since the edges are Euclidean distances, we
have:
c(u, v) + c(z, w) = c(z, c) + c(c, w) + c(u, c) + c(c, v).
1
2
MICHELLE BODNAR
By the triangle inequality we have
c(z, c) + c(c, v) ≥ c(z, v) and c(u, c) + c(c, w) ≥ c(u, w).
Combining these with the equality above gives:
c(u, v) + c(z, w) ≥ c(z, v) + c(u, w).
Thus, path P incurs a smaller total cost than the original path. But the original path was assumed
to be optimal! This is a contradiction, so it must be the case that no optimal path can have crossing
edges.
3. Show how to transform any instance of the traveling salesman probem (in polynomial time)
into an instance of the traveling salesman problem which satisfies the triangle inequality. The two
instances must have the same set of optimal tours.
Let m be some value which is larger than any edge weight. If c(u, v) denotes the cost of the edge
from u to v, then modify the weight of the edge to be H(u, v) = c(u, v)+m. (In other words, H is our
new cost function). First we show that this forces the triangle inequality to hold. Let u, v, and w
be vertices. Then we have H(u, v) = c(u, v)+m ≤ 2m ≤ c(u, w)+m+c(w, v)+m = H(u, w)+H(w, v).
Note: it’s important that the weights of edges are nonnegative.
Next we must consider how this affects the weight of an optimal tour. First, any optimal tour
has exactly n edges (assuming that the input graph has exactly n vertices). This can be shown by
first proving that any cycle on n vertices which visit every vertex exactly once must have n eges.
Thus, the total cost added to any tour in the original setup is nm. Since the change in cost is
constant for every tour, the set of optimal tours must remain the same.
Thanks for being awesome students! May your algorithms always be fast and your solutions
always be close to optimal.