CS255
Chris Pollett
May 8, 2019
bestS' = ∅ bestW = 0 foreach S' ⊆ S: w := ∑x ∈ S'x if w > bestW and w ≤ t: bestW := w bestS' := S' return bestS'
EXACT-SUBSET-SUM(S, t) Here S = {x[1], ... x[n]} 1 n = |S| 2 L[0] = (0) 3 for i = 1 to n 4 L[i] = MERGE-LISTS(L[i-1], L[i-1] + x[i]) 5 remove from L[i] every element that is greater than t 6 return the largest element in L[n]
TRIM(L, δ) We assume L = (y[1], ..., y[m]) 1 let m be the length of L 2 L' = (y[1]) 3 last = y[1] 4 for i = 2 to m 5 if y[i] > last * (1 + δ) // y[i] ≥ last because L is sorted 6 append y[i] to L' 7 last = y[i] 8 return L'
APPROX-SUBSET-SUM(S, t, ε) 1 n = |S| 2 L[0] = (0) 3 for i = 1 to n 4 L[i] = MERGE-LISTS(L[i-1], L[i-1] + x[i]) 5 L[i] = TRIM(L[i], ε/2n) 6 remove from L[i] every element that is greater than t 7 let zstar be the largest value in L[n] 8 return zstar
line 2: L[0] = ( 0 ) line 4: L[1] = ( 0, 104 ) line 5: L[1] = ( 0, 104 ) line 6: L[1] = ( 0, 104 ) line 4: L[2] = ( 0, 102, 104, 206 ) line 5: L[2] = ( 0, 102, 206 ) line 6: L[2] = ( 0, 102, 206 ) line 4: L[3] = ( 0, 102, 201, 206, 303, 407 ) line 5: L[3] = ( 0, 102, 201, 303, 407 ) line 6: L[3] = ( 0, 102, 201, 303 ) line 4: L[4] = ( 0, 101, 102, 201, 203, 302, 303, 404 ) line 5: L[4] = ( 0, 101, 201, 302, 404 ) line 6: L[4] = ( 0, 101, 201, 302 )
Theorem. APPROX-SUBSET-SUM is a fully `p`-time approximation scheme for the subset-sum problem.
Proof. Trimming and removing elements of value greater than `t` maintain the property that every element of `L[i]`, which from now on we'll write as `L_i`, is also a member of `P_i`. So zstar, which we'll write from now on as `z^star`, returned by line 8 is the sum of some subset of `S`. let `y^star in P_n` denote an optimal solution to the subset-sum problem. From line 6, we know that `z^(star) leq y^star`. So we need to show `y^star/z^star le 1 +epsilon` and that the algorithm runs in polynomial time in both `1/epsilon` and the input size.
From the definition of trimming one can show for every element `y in P_i` that is at most `t` there exists a `z in L_i` such that
`y/(1+epsilon/(2n))^i le z le y`.
In particular as `y^star in P_n`, there exists an element `z in L_n` such that
`y^star/(1+epsilon/(2n))^n le z le y^star`,
and so,
`y^star/z leq (1+epsilon/(2n))^n`.
Since there exists a `z in L_n` satisfying the above, it must also hold for `z^star`, the largest element of `L_n`. Therefore
`y^star/z^star le (1+epsilon/(2n))^n`.
We now argue `(1+epsilon/(2n))^n le 1 + epsilon` to get `y^star/z^star le 1 + epsilon`. To see this notice
`lim_(n -> infty) (1 + epsilon/(2n))^n = e^(epsilon/2)` and as `d/(dn)(1 + epsilon/(2n))^n > 0`, `(1 + epsilon/(2n))^n` increases with
`n`. So we have
`(1 + epsilon/(2n))^n le e^(epsilon/2)`
`le 1 + epsilon/2 + (epsilon/2)^2` (looking at terms in Taylor series)
`le 1 + epsilon`.
So we have that the algorithm satisfies the desired approximation ratio, to complete the proof we need to show a bound on the length of `L_i`.
After trimming, successive elements `z` and `z'` of `L_i` must have the relationship `(z')/z > 1 + epsilon/(2n)`. That is, they must
differ by a factor of at least `1 + epsilon/(2n)`. So each list contains the value 0, possibly the value 1, and up to `|__ log_(1+epsilon/(2n)) t__|` additional
values. So the number of elements in each list `L_i` is at most
`log_(1+epsilon/(2n)) t +2 = (ln t)/(ln(1+epsilon/(2n))) + 2`
`le (2n(1 + epsilon/(2n)) ln t)/(epsilon) + 2`
`< (3n ln t)/epsilon +2`
which is polynomial in both `n` and `epsilon` as `ln t < n` as it is provided as part of the input.
Theorem. For any undirected graph `G=(V, E)` with `n` vertices and `m` edges there is a cut
`A`, `B` such that
`|{(u, v) in E | u in A and v in B}| ge m/2`
Proof. Consider the following experiment: For each vertex flip an unbiased coin and if it is heads put the vertex in `A`; otherwise, put the vertex in `B`.
For an edge `(u,v)`, the probability that its end-points are in different sets is 1/2. By linearity of expectation, the expected number of edges with end-points in different sets is thus `m/2`. It follows by the probabilistic method that there must be a partition satisfying the theorem. QED.
Remark. The above experiment essentially gives us an algorithm to find a cut of expected size `m/2`. In general, the probabilistic method will be closely tied with randomized algorithms for constructing objects.