04.09.2013 Views

Algorithm Design

Algorithm Design

Algorithm Design

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

202<br />

Chapter 4 Greedy <strong>Algorithm</strong>s<br />

leaf v, and ff u is the parent of v in T, then h(u) >_ h(v). We place each point<br />

in P at a distinct leaf in T. Now, for any pair of points p~ and Pi, their<br />

distance ~(p~, Pi) is defined as follows. We determine the least common<br />

ancestor v in T of the leaves containing p~ and Pi, and define ~(p~,<br />

We say that a hierarchical metric r is consistent with our distance<br />

function d if, for all pairs i,j, we have r(p~,pl) _< d(p~,Pi).<br />

Give a polynomial-time algorithm that takes the distance function d<br />

and produces a hierarchical metric ~ with the following properties.<br />

(i) ~ is consistent with d, and<br />

(ii) ff ~’ is any other hierarchical metric consistent with d, then ~’(P~,Pi) 0. The Minimum<br />

Spanning Tree Problem, on the other hand, is a minimization problem of<br />

a very different flavor: there are now just a~ finite number of possibilities,<br />

for how the minimum might be achieved--rather than a continuum of<br />

possibilities--and we are interested in how to perform the computation<br />

without having to exhaust this (huge) finite number of possibilities.<br />

27.<br />

One Can ask what happens when these two minimization issues<br />

are brought together, and the following question is an example of this.<br />

Suppose we have a connected graph G = (V, E). Each edge e now has a timevarying<br />

edge cost given by a function fe :R-+R. Thus, at time t, it has cost<br />

re(t). We’l! assume that all these functions are positive over their entire<br />

range. Observe that the set of edges constituting the minimum spanning<br />

tree of G may change over time. Also, of course, the cost of the minimum<br />

spanning tree of G becomes a function of the time t; we’ll denote this<br />

function ca(t). A natural problem then becomes: find a value of t at which<br />

cG(t) is minimized.<br />

Suppose each function fe is a polynomial of degree 2: re(t) =aet z +<br />

bet + Ce, where ae > 0. Give an algorithm that takes the graph G and the<br />

values {(ae, be, ce) : e ~ E} and returns a value of the time t at which the<br />

minimum spanning tree has minimum cost. Your algorithm should run<br />

in time polynomial in the number of nodes and edges of the graph G. You<br />

may assume that arithmetic operations on the numbers {(ae, be, q)} can<br />

be done in constant time per operation.<br />

In trying to understand the combinatorial StlXlcture of spanning trees,<br />

we can consider the space of all possible spanning trees of a given graph<br />

and study the properties of this space. This is a strategy that has been<br />

applied to many similar problems as well.<br />

28.<br />

29.<br />

30.<br />

Exercises<br />

Here is one way to do this. Let G be a connected graph, and T and T’<br />

two different spanning trees of G.. We say that T and T’ are neighbors if<br />

T contains exactly one edge that is not in T’, and T"contains exactly one<br />

edge that is not in T.<br />

Now, from any graph G, we can build a (large) graph 9~ as follows.<br />

The nodes of 9~ are the spanning trees of G, and there is an edge between<br />

two nodes of 9C if the corresponding spanning trees are neighbors.<br />

Is it true that, for any connected graph G, the resulting graph ~<br />

is connected? Give a proof that ~K is always connected, or provide an<br />

example (with explanation) of a connected graph G for which % is not<br />

connected.<br />

Suppose you’re a consultant for the networking company CluNet, and<br />

they have the following problem. The network that they’re currently<br />

working on is modeled by a connected graph G = (V, E) with n nodes.<br />

Each edge e is a fiber-optic cable that is owned by one of two companies-creatively<br />

named X and Y--and leased to CluNet.<br />

Their plan is to choose a spanning tree T of G and upgrade the links<br />

corresponding to the edges of T. Their business relations people have<br />

already concluded an agreement with companies X and Y stipulating a<br />

number k so that in the tree T that is chosen, k of the edges will be owned<br />

by X and n - k - 1 of the edges will be owned by Y.<br />

CluNet management now faces the following problem. It is not at all<br />

clear to them whether there even exists a spanning tree T meeting these<br />

conditions, or how to find one if it exists. So this is the problem they put<br />

to you: Give a polynomial-time algorithm that takes G, with each edge<br />

labeled X or Y, and either (i) returns a spanning tree with e~xactly k edges<br />

labeled X, or (ii) reports correctly that no such tree exists.<br />

Given a list of n natural numbers all, d 2 ..... tin, show how to decide<br />

in polynomial time whether there exists an undirected graph G = (V, E)<br />

whose node degrees are precisely the numbers d~, d2 ..... dn. (That is, ff<br />

V = {Ul, v2 ..... vn}, then the degree of u~ should be exactly d v) G should not<br />

contain multiple edges between the same pair of nodes, or "!oop" edges<br />

with both endpoints equal to the same node.<br />

Let G = (V, E) be a graph with n nodes in which each pair of nodes is<br />

joined by an edge. There is a positive weight w~i on each edge (i,]); and<br />

we will assume these weights satisfy the triangle inequality tv~k

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!