Comp 360, Problem Set #5 Solutions

Comp 360, Problem Set #5 Solutions
1
1.1
Online Bipartite Matching
(a)
The most straightforward algorithm is a greedy algorithm that match the first valid vertex. The algorithm
is as follow: For every edge (i, j) in the perfect matching of M , either i or j is present in the matching
Algorithm 1 Online Matching
Input: i: new arrival ∈ L; Rvalid : that has edges to i and not picked before
Output: j: picked vertex ∈ R, or NULL
1: procedure Online Matching
2:
if Rvalid is not empty then
3:
return first j in R
4:
else
5:
return NULL
generated by the algorithm. Otherwise, the matching can be augmented by adding (i, j). So at least
vertices in the matching. Thus, the competitive ration is at most 2.
1.2
n
2
(b)
An adversary can limit the size of matching to n/2 in the following way: Let the first n/2 that arrive
have edges to all the vertices in V . Clearly, the adversary can determine the vertices in V that will be
matched. Let the next n/2 vertices that arrive contain edges only to those vertices in V which are already
matched. The input graph has a perfect matching but the second half of the vertices are not matched.
Hence our analysis is tight for the deterministic case that any deterministic algorithm cannot do better
than the obvious algorithm in (a).
2
Find the hole
The algorithm is as follow: Define f (i) = 2i steps. In the worst case scenario, n is just some small distance
Algorithm 2 Find the holde
1: procedure Find the hole
2:
for i=0; n is not found; i++ do
3:
walk 2i steps in the (−1)i direction
d ≥ 0 from a distance we turn around and head to the opposite direction. Suppose n = f (m) + d. The
1
distance we travelled is
m+1
m+1
2 ∗ ∑ f (i) + n = 2 ∗ ∑ 2i + n
i=0
i=0
m+2
= ∑ 2i + n
i=0
m+3
=2
− 1 + 2m + d
= 9 ∗ 2m + d − 1
= 9(f (m) + d) − 1
≤ 9(f (m) + d)
= 9n
Thus, the competitive ration of this deterministic algorithm is at most 9.
Problem 3
Solution: For given n, we can run the algorithm A 2k + 1 times on the input x and obtain outputs
y1 , y2 , . . . , y2k+1 . Now sort these outputs in increasing order and pick the middle element, say yk+1 , where
n = 2k + 1 (without loss of generalitn we can assume n is odd). We claim that with high probability, i.e.
close to 1, yk+1 is in the range [f (x)/2, 2f (x)]. What is the probability that this is not the case? If yk+1
is not in the range [f (x)/2, 2f (x)], say it is less than f (x)/2, then all the elements before him in the
sorted order are also less than f (x)/2. If yk+1 is greater than 2f (x) then all the elements after him are
also greater than 2f (x). So in both cases, if yk+1 is not in the range [f (x)/2, 2f (x)], then we have at least
k + 1 outputs that are also not in the same range.
Let’s bound the probability that the median is not in the range. The probability that exactly i of the
) ⋅ (2/3)2k+1−i (1/3)i . So the the probability that at least k + 1 of the
outputs are outside the range is (2k+1
i
outputs are outside the range is
2k+1
2k + 1
) ⋅ (2/3)2k+1−i (1/3)i .
∑ (
i
i=k+1
2k+1
2k
Notice that (2/3)2k+1−i (1/3)i ≤ (2/3)k (1/3)k+1 for all i ≥ k +1, and ∑2k+1
i=k+1 ( i ) ≤ 2 . Thus the probability
above can be upper bounded by (2/3)k (1/3)k+1 ⋅ 22k ≤ 1/3 ⋅ (8/9)k . Thus, if we take k to be (log8/9 1/e)n.
The success probability is at least 1 − e−n /3.
Problem 4
Solution: Let G be the following graph on vertices {s, t, v1 , . . . , vn−2 }, where s is connected by one edge
to each of vi ’s and each vi is attached to t by two parallel edges. There are no other edges. The minimum
s − t cut in this setting will be {s}, and {v1 , . . . , vn−2 , t}. To find this cut, the algorithm must contract each
vi into t but not s, which happens with probability exactly 2/3 (the algorithm must choose one of the two
parallel edges going to t), thus the probability that the algorthm finds the minimum s − t cut is at most
(2/3)n−2 which is exponentially small.
2