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.

508<br />

Chapter 8 NP and Computational Intractability<br />

of the words. (Multiple copies of words are okay here; so for example, if<br />

the set of refrigerator magnets includes two copies each of C, A, and T, . .....<br />

it would be okay to spell out CAT twice.)<br />

This turned out to be pretty difficult, and it was only later that you<br />

realized a plausible reason for this. Suppose we consider a general version<br />

of the problem of Using Up All the Refrigerator Magnets, where we replace<br />

the English alphabet by an arbitrary collection of syznbols, and we model<br />

Madison’s vocabulary as an arbitrary set of strings over this collection of<br />

symbols. The goal is the same as in the previous paragraph.<br />

Prove that the problem of Using Up All the Refrigerator Magnets is<br />

9.~CPo-~s replete"<br />

ider the following problem. You are managing a communication<br />

network, modeled by a directed graph G = (V, E). There are c users who<br />

are interested in malting use of this network. User i (for each i = t, 2 ..... c)<br />

issues a request to reserve a specific path Pi in G on which to transmit<br />

data.<br />

You are interested in accepting as many of these path requests as<br />

possible, subject to the following restriction: ff you accept both Pi and<br />

then Pi and Pj cannot share any nodes.<br />

Thus, the Path Selection Problem asks: Given a directed graph G =<br />

(V, E), a set of requests P1, P2 ..... pc--each of which must be a path in<br />

G--and a number k, is it possible to select at least k of the paths so that<br />

no two of the selected paths share any nodes?<br />

Prove that Path Selection is NP-complete.<br />

Jl0. Your friends at WebExodus have recently been doing some consullAng<br />

work for companies that maintain large, publicly accessible Web sites-contractual<br />

issues prevent them from saying which ones--and they’ve<br />

come across the following Strategic Advertising Problem.<br />

A company comes to them with the map of a Web site, which we’ll<br />

model as a directed graph G = (V, E). The companY also provides a set of<br />

t trails typically followed by users of the site; we’ll model these trails as<br />

directed paths P1, P2 ..... Pt in the graph G (i.e., each Pi is a path in G).<br />

The companY wants WebExodus to answer the following question<br />

for them: Given G, the paths {P~}, and a number k, is it possible to place<br />

advertisements on at most k of the nodes in G, so that each path P~<br />

includes at least one node containing an advertisement? We’ll call this<br />

the Strategic Advertising Problem, with input G, {P~ : i = 1 ..... t}, and k.<br />

Your friends figure that a good algorithra for this will make them all<br />

rich; tmfortunately, things are never quite this simple.<br />

Exercises<br />

Prove that Strategic Advertising is NP-complete.<br />

(b) Your friends at WebExodus forge ahead and write a pretty fast algorithm<br />

8 that produces yes/no answers to arbitrary instances of the<br />

Strategic Advertising Problem. You may assume that the algorithm<br />

8 is always correct.<br />

Using the algorithm 8 as a black box, design an algorithm that<br />

takes input G, {Pi}, and k as in part (a), and does one of the following<br />

two things:<br />

- Outputs a set of at most k nodes in G so that each path Pi includes<br />

at least one of these nodes, or ’ ~<br />

- Outputs (correctly) that no such set of at most k n6des exists.<br />

Your algorithm should use at most a polynomial number of steps, together<br />

with at most a polynomial number of calls to the .algorithm 8.<br />

11. As some people remember, and many have been told, the idea of hypertext<br />

predates the World Wide Web by decades. Even hypertext fiction is<br />

a relatively old idea: Rather than being constrained by the linearity of<br />

the printed page, you can plot a story that consists of a collection of<br />

interlocked virtual "places" joined by virtual "passages. ’’4 So a piece of<br />

hypertext fiction is really riding on an tmderlying directed graph; to be<br />

concrete (though narrowing the fuli range of what the domain can do),<br />

we’ll model this as follows.<br />

Let’s view the structure of a piece of hypertext fiction as a directed<br />

graph G = (V, E). Each node u e V contains some text; when the reader is<br />

currently at u, he or she can choose to follow any edge out of u; and if the<br />

reader chooses e = (u, v), he or she arrives next at the node v. There is a<br />

start node s ~ V where the reader begins, and an end node t ~ V; when the<br />

reader first reaches t, the story ends. Thus any path from s to t is a valid<br />

plot of the story. Note that, unlike one’s experience using a Web browser,<br />

there is not necessarily a way to go back; once you’ve gone from a to ~,<br />

~ ~ou might not be able to ever return to u.<br />

In this way, the hypertext structure defines a huge number of different<br />

plots on the same underlying content; and the relationships among<br />

all these possibilities can grow very intricate. Here’s a type of problem<br />

one encounters when reasoning about a structure 3ike this. Consider a<br />

piece of hypertext fiction built on a graph G = (V, E) in which there are<br />

certain crucial thematic elements: love, death, war, an intense desire to<br />

major in computer science, and so forth. Each thematic element i is represented<br />

by a set Ti _c V consisting of the nodes in G at which this theme<br />

See, e.g., http://www.eastgate.com.<br />

509

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

Saved successfully!

Ooh no, something went wrong!