Algorithms: CSE 202 - Homework II
Algorithms: CSE 202 - Homework II
Let r∗ be the maximum ratio achievable by a simple cycle. One way to determine r∗ is by binary
search: by first guessing some ratio r, and then testing whether it is too large or too small.
Consider any positive r > 0. Give each edge (i, j) a weight of wij = rcij − pj .
(b) Show that if all cycles in the graph have strictly positive weight, then r > r∗ .
(c) Give an efficient algorithm that takes as input a desired accuracy > 0 and returns a simple
cycle C for which r(C) ≥ r∗ − . Justify the correctness of your algorithm and analyze its
running time in terms of |V |, , and R = max(i,j)∈E (pj /cij ).
1
Your friends want to use the Web site to determine the fastest way to travel through the
directed graph from their starting point to their intended destination. (You should assume that
they start at time 0, and that all predictions made by the Web site are completely correct.) Give a
polynomial-time algorithm to do this, where we treat a single query to the Web site (based on a
specific edge e and a time t) as taking a single computational step.
2
One can ask what happens when these two minimization issues are brought together, and the
following question is an example of this. Suppose we have a connected graph G = (V, E). Each
edge e now has a time-varying edge cost given by a function fe : R → R. Thus, at time t, it has cost
fe (t). We’ll assume that all these functions are positive over their entire range. Observe that the set
of edges constituting the minimum spanning tree of G may change over time. Also, of course, the
cost of the minimum spanning tree of G becomes a function of the time t; we’ll denote this function
cG (t). A natural problem then becomes: Find a value of t at which cG (t) is minimized.
Suppose each function fe is a polynomial of degree 2: fe (t) = ae t2 + be t + ce ; where ae > 0. Give
an algorithm that takes the graph G and the values {(ae , be , ce ) : e ∈ E} and returns a value of the
time t at which the minimum spanning tree has minimum cost. Your algorithm should run in time
polynomial in the number of nodes and edges of the graph G. You may assume that arithmetic
operations on the numbers {(ae , be , ce )} can be done in constant time per operation.
3
then to E3 , and so on, to an edge set Eb . For i = 0, 1, 2, . . . , b, let Gi denote the graph (V, Ei ). So
if we were to watch the structure of the network on the nodes V as a “time lapse,” it would look
precisely like the sequence of graphs G0 , G1 , G2 , . . . , Gb−1 , Gb . We will assume that each of these
graphs Gi is connected.
Now consider two particular nodes s, t ∈ V . For an s-t path P in one of the graphs Gi , we define
the length of P to be simply the number of edges in P , and we denote this `(P ). Our goal is to
produce a sequence of paths P0 , P1 , . . . , Pb so that for each i, Pi is an s-t path in Gi . We want the
paths to be relatively short. We also do not want there to be too many changes–points at which
the identity of the path switches. Formally, we define changes(P0 , P1 , . . . , Pb ) to be the number of
indices i (0 ≤ i ≤ b − 1) for which Pi 6= Pi+1 .
Fix a constant K > 0. We define the cost of the sequence of paths P0 , P1 , . . . , Pb to be
b
X
cost(P0 , P1 , . . . , Pb ) = `(Pi ) + K · changes(P0 , P1 , . . . , Pb ).
i=0
(a) Suppose it is possible to choose a single path P that is an s-t path in each of the graphs
G0 , G1 , . . . , Gb . Give a polynomial-time algorithm to find the shortest such path.
4
On the other hand, selling 40,000 shares on day 1 yields a price of 89 per share, and selling the
remaining 60,000 shares on day 2 results in a price of 59 per share, for a total income of 7,100,000.