Practice Problem Set 3

Transcription

Practice Problem Set 3
CSE 202: Design and Analysis of Algorithms
Winter 2015
Practice Problem Set 3
Instructor: Kamalika Chaudhuri
Due on: Do not submit
Problem 1(Easy)
You are given a max flow problem: a directed graph G = (V, E) where each e ∈ E has capacity c(e) = 1, a
source s and a sink t. You are also given a parameter k. You would like to find a set F of at most k edges
to delete from the graph such that the max s − t flow in G0 = (V, E \ F ) is as small as possible. Design an
algorithm to find F ; the running time of your algorithm should be polynomial in |E| and |V |.
Problem 2 (Harder)
Consider an arbitrary directed network (G = (V, E), s, t, ce ) in which we want to find the max-flow. Assume
for simplicity that all edge capacities are at least 1, and define the capacity of an s-t path to be the smallest
capacity of its constituent edges. The fattest path from s to t is the path with the most capacity.
1. Describe a O(|E| log |V |) algorithm to find the fattest path in G.
2. Show that the maximum flow in G is the sum of individual flows along at most |E| paths from s to t.
3. Now show that if we always increase flow along the fattest path in the residual graph, then the
Ford-Fulkerson algorithm will terminate in at most O(|E| log F ) iterations, where F is the size of the
maximum flow. (Hint: The analysis of the approximation algorithm for the set cover problem might
help.)
Problem 3
There are n processes P1 , . . . , Pn that all want access to a single database. The problem is that if more than
one process tries to access the database at the same time, none of them will succeed due to a particular
locking mechanism. So instead, we use the following randomized protocol:
• For time t = 1, 2, . . .
– Each processor flips a coin with heads probability 1/n
– If heads, it attempts to access the database at time t
1. Fix any time t, and let Et,i be the event that process Pi successfully accesses the database at that time.
This means that Pi ’s coin flip turns up heads, whereas the coin flip of every other processor turns up
tails. What is Pr(Et,i ) exactly? You may need to use the approximations 1 − x ≤ e−x .
2. Suppose that at time t, there are still k processes that have not yet been able to access the database.
What is the expected additional time it takes until one of them gets access? Give your answer in terms
of k and n. Hint: Start by finding the probability that one of these k processes gets access at time t.
3. Roughly what is the expected time by which all processes will have been able to access the database?
Problem 4
In class, we talked about a randomized algorithm for finding the minimum cut of a graph G = (V, E).
Sometimes we are interested in finding the maximum cut, that is, a partition of V into two groups V1 and V2
such that the number of edges between V1 and V2 is maximized. Here is a possible algorithm for maximum
cut:
• Select V1 as follows: for each u ∈ V , include u in V1 with probability 1/2.
• Let V2 = V − V1 .
1. What is the expected size of the resulting cut, as a function of |E|?
2. This algorithm might not return the maximum cut. However, can you show that it is, in expectation,
at least half as big as the maximum cut?