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.

324<br />

Chapter 6 Dynamic Programming<br />

13.<br />

We’d like to place copies of the fries at the servers so as to minimize<br />

the sum of placement and access costs. Formally, we say that a configu-<br />

ration is a choice, for each server Si with i = 1, 2 ..... n - 1, of whether to<br />

place a copy of the file at Si or not. (Recall that a copy is always placed at<br />

Sn.) The total cost of a configuration is the sum of all placement costs for<br />

servers with a copy of the file, plus the sum of all access costs associated<br />

14,<br />

with all n servers.<br />

Give a p olynomial-time algorithm to find a configuration of minimum<br />

total cost.<br />

The problem of searching for cycles in graphs arises naturally in financial<br />

trading applications. Consider a firm that trades shares in n different<br />

companies. For each pair i ~j, they maintain a trade ratio rq, meaning<br />

that one share of i trades for rq shares ofj. Here we allow the rate r to be<br />

fractional; that is, rq = ~ means that you can trade ~ee shares of i to get<br />

two shares of j.<br />

A trading cycle for a sequence of shares ~1, iz ..... ~k consists of<br />

successively trading shares in company il for shares in company ~z, then<br />

shares in company iz for shares i3, and so on, finally trading shares in ik<br />

back to shares in company ~. After such a sequence of trades, one’ends up<br />

with shares in the same company i~ that one starts with. Trading around a<br />

cycle is usually a bad idea, as you tend to end up with fewer shares than<br />

you started with. ]But occasionally, for short periods of time, there are<br />

opportunities to increase shares. We will call such a cycle an opportunity<br />

cycle, if trading along the cycle increases the number of shares. This<br />

happens exactly if the product of the ratios along the cycle is above 1. In<br />

analyzing the state of the market, a firm engaged in trading would like<br />

to know if there are any opportunity cycles.<br />

Give a polynomial-time algorithm that finds such an opportunity<br />

cycle, if one exists.<br />

A large collection of mobile wireless devices can naturally form a network<br />

in which the devices are the nodes, and two devices x and y are connected<br />

by an edge if they are able to directly communicate with each other (e.g.,<br />

by a short-range radio link). Such a network of wireless devices is a highly<br />

dynamlc object, in which edges can appear and disappear over time as<br />

the devices move around. For instance, an edge (x, y) might disappear as x<br />

and y move far apart from each other and lose the ability to communicate<br />

directly.<br />

In a network that changes over time, it is natural to look for efficient<br />

ways of maintaining a path between certain designated nodes. There are<br />

Exercises<br />

two opposing concerns in maintaining such a path: we want paths that are<br />

short, but we also do not want to have to change the path frequently as the<br />

network structure changes. (That is, we’d like a single path to continue<br />

working, if possible, even as the network gains and loses edges.) Here is<br />

a way we might model this problem.<br />

Suppose we have a set of mobile nodes v, and at a particular point in<br />

time there is a set E 0 of edges among these nodes. As the nodes move, the<br />

set of edges changes from E 0 to E~, then to E2, then to E3, and so on, to an<br />

edge set E b. Fir i = 0, 1, 2 ..... b, let G~ denote the graph (V, E~). So if we were<br />

to watch the structure of the network on the nodes V as a "time lapse," it<br />

would look precisely like the sequence of graphs Go, G~, G2 ..... Gb_~, G~.<br />

We will assume that each of these graphs G~ is connected.<br />

Now consider two particular nodes s, t ~ V. For an s-t path P in one<br />

of the graphs Gi, we define the length of P to be simply the number of<br />

edges in P, and we denote this g(P). Our goal is to produce a sequence of<br />

paths P0, P~ ..... P~ so that for each i, Pg is an s-t path in G~. We want the<br />

paths to be relatively short. We also do not want there to be too many<br />

changes--points at which the identity of the path switches. Formally, we<br />

define changes(Po, P~ .....P~) to be the number of indices i (0 < i < b - 1)<br />

for which Pi # P~+I"<br />

Fix a constant K > 0. We define the cost of the sequence of paths<br />

PO, P1 ..... Pb tO be<br />

b<br />

COSt(Po, PI ..... Pb) = ~ f-(Pi) + K. changes(Po, P~ ..... Pb).<br />

(a) Suppose it is possible to choose a single path P that is an s-t path in<br />

each of the graphs Go, G~ .....Gb. Give a polynomial-time algorithm<br />

to find the shortest such path.<br />

(b) Give a polynomial-time algorithm to find a sequence of paths<br />

P0, P~ .....P~ of minimum cost, where P~ is an s-t path in G~ for<br />

i=0,1 .....b.<br />

15. On most clear days, a group of your friends in the Astronomy Department<br />

gets together to plan out the astronomical events ~they’re going to try<br />

observing that night. We’ll make the following assumptions about the<br />

events.<br />

o There are n events, which for simplicity we’ll assume occur in sequence<br />

separated by exactly one minute each. Thus event j occurs<br />

at minute j; if they don’t observe this event at exactly minute j, then<br />

they miss out on it.<br />

325

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

Saved successfully!

Ooh no, something went wrong!