Claim
- All
f̂(S)(or allf̃(S)) values can be computed sequentially inO*(3^n)time and poly(n) space24:20. - Time accounting assumes evaluating
fcosts unit time; for k-colorability evaluatingfis poly-time, since you only have to check whether a set is independent24:20,25:11.
The algorithm
- Loop over all
S, and for eachScomputef̂(S) = Σ_{R ⊆ S} f(R)by brute force — no recursion, no memoization25:55,26:24. - Do not store the result: fold each
f̂(S)immediately into the running sumΣ_S (−1)^{|V−S|} f̂(S)^k, then throw it away26:42. That is what keeps the space polynomial.
Time analysis
- Cost for one
Sis proportional to its number of subsets,2^{|S|}27:06. - Total:
Σ_{S ⊆ V} 2^{|S|} = Σ_{i=0}^{n} C(n,i) · 2^i = 3^n— the same binomial identity used last lecture27:31,27:47.