Download Time Completxity notees and more Summaries Computer Science in PDF only on Docsity!
CS 6820 - Analysis of Algorithms | Notes: Complexity + Approximation Weeks 7-9 | based on Sipser ch. 7-8, Vazirani approximation algs book
1. Complexity Classes - Quick Review
(This is a compressed refresher; we went fast bc everyone took theory of computing)
- P: decision problems solvable in det. poly-time on TM
- NP: decision problems verifiable in poly-time given a "certificate". Equiv: solvable in poly-time on NDTM.
- co-NP: complement of NP. If L in NP, complement of L in co-NP. NOT the same as NP (probably).
- NP-hard: at least as hard as hardest problem in NP (via poly-time reduction)
- NP-complete: NP-hard AND in NP. The "hardest" problems in NP. P vs NP - the big open question. Most people believe P != NP but we've made basically zero progress on proving it. Best lower bounds for SAT are like n^1.something on restricted models. Also important: if P=NP then NP=co-NP. But NP=co-NP doesn't imply P=NP. And: if any NP-complete problem is in P, then ALL of NP is in P.
1.1 Other Complexity Classes (mentioned in class)
- PSPACE: solvable w/ poly space (and potentially exp time). PSPACE-complete: QBF (quantified boolean formula).
- EXP: solvable in exp time. Clearly PSPACE ⊆EXP.
- BPP: solvable in poly time w/ randomization and error prob <= 1/3 (can be reduced). Probably = P but not proven.
- RP: one-sided error randomized poly time. ZPP: zero-error expected poly time. RP ∩ co-RP = ZPP. Known: P ⊆ NP ⊆ PSPACE ⊆ EXP. Also P ⊊ EXP (time hierarchy thm). But NP ⊊PSPACE is not proven!!
2. Cook-Levin Theorem
Cook 1971, Levin 1973 (independently). SAT is NP-complete. Theorem: SAT (satisfiability of boolean formulas) is NP-complete.
Proof sketch (membership in NP is easy - certificate is satisfying assignment). Hardness: show every NP language reduces to SAT. Key idea: execution of NDTM M on input w can be encoded as a polynomial-size boolean formula that's satisfiable iff M accepts w. The formula encodes:
- Cell(i,j,s): tape cell i at time j contains symbol s
- Head(i,j): head at position i at time j
- State(q,j): machine in state q at time j Then write clauses for: initial config, valid transitions, acceptance condition. Each clause is poly size, total formula is poly size. QED (roughly) 3-SAT: every clause has exactly 3 literals. Also NP-complete (reduce from SAT: replace long clauses w/ chains of 3-literal clauses using aux variables). <- 3-SAT is the workhorse for showing NP-hardness of other problems. Know this reduction cold.
3. Common NP-Complete Problems & Reductions
Must know these reductions: 3-SAT -> Independent Set:
- Given 3-CNF formula w/ k clauses, create graph G where:
- Each clause becomes a triangle (3 nodes, one per literal)
- Add edge between any node x and node NOT-x across triangles (conflicting literals)
- Formula satisfiable iff G has independent set of size k (one node per clause = one satisfied literal per clause) Independent Set -> Clique:
- Take complement graph G' (edge iff no edge in G). S is indep. set in G iff S is clique in G'. Independent Set -> Vertex Cover:
- S is indep. set iff V\S is vertex cover. (Edge (u,v): if neither u nor v in cover, then both in indep set, so edge within indep set - contradiction). 3-SAT -> 3-Coloring:
- For each var x: create x-node and NOT-x-node, connected to each other and to a "base" palette node
- Gadget for each clause ensures clause is satisfied iff clause nodes get valid coloring
- This one is trickier to remember - draw it out
4. Approximation Algorithms
For NP-hard optimization problems, can we find near-optimal solutions in poly time? Approximation ratio: algorithm A has ratio rho if for all instances, OPT/rho <= A(I) <= rho*OPT. (Convention differs: for minimization, ratio >= 1; for maximization, <= 1 or >=1/rho depending on author) !! Important: Vazirani uses approx ratio as rho where A(I)/OPT <= rho for minimization. Some papers use OPT/A(I) for maximization. Be careful about convention when reading papers.
4.1 Vertex Cover
Problem: find min set S of vertices s.t. every edge has at least one endpoint in S. 2-approx algorithm (classic):
- Pick any uncovered edge (u,v)
- Add BOTH u and v to cover
- Remove all edges incident to u or v
- Repeat Analysis: let M be maximal matching produced. |M| <= OPT (each opt vertex covers at most one matching edge). Our solution is 2|M|. So solution <= 2*OPT. Can we do better? Known: 2-approx can't be improved to (2-eps) assuming the Unique Games Conjecture (Khot & Regev). Without UGC, best known is still ~2. Note: vertex cover is in NP so there's an exact alg (just exponential). The approx lets us run in poly time.
4.2 Set Cover
Generalization of vertex cover. Universe U of n elements, collection of sets, each w/ a cost. Find min-cost sub- collection that covers U. Greedy algorithm: repeatedly pick set w/ best cost/new-elements-covered ratio. Approximation ratio: H_n = 1 + 1/2 + 1/3 + ... + 1/n = O(log n) Lower bound: Can't do better than (1-eps)*ln(n) unless NP ⊆DTIME(n^{log log n}) (Feige 1998). So greedy is essentially optimal! ??? : Is the hardness result based on P!=NP or on stronger assumptions? Check Feige 98 - I think it's a stronger assumption actually
4.3 Traveling Salesman Problem (TSP)
Given complete weighted graph, find min-cost Hamiltonian cycle. General TSP: no poly-time approx w/ any constant ratio unless P=NP. (If c-approx existed, could solve Hamiltonian path in poly time via reduction - proof in Sipser) Metric TSP (triangle inequality holds): better story. 2-approximation (MST heuristic):
- Compute MST T
- Double edges of T to get Eulerian multigraph
- Find Euler tour, shortcut repeated vertices Analysis: OPT >= MST cost (removing any edge from opt cycle gives spanning tree). 2MST cost >= 2OPT... wait. So our tour cost <= 2MST <= 2OPT. OK yes that's right. Christofides 1976 (3/2 approx):
- Compute MST T
- Find min-weight perfect matching M on vertices w/ odd degree in T
- T + M forms Eulerian graph (all vertices even degree)
- Euler tour + shortcutting -> Hamiltonian cycle Cost of M <= OPT/2 (partition opt cycle into two matchings, take cheaper one). Total cost <= MST + OPT/2 <= OPT + OPT/2 = 3/2 * OPT. 3/2 bound stood for 47 years! Karlin et al 2020 got 3/2 - epsilon for a tiny epsilon. NOT practical but theoretically first improvement ever.
4.4 Knapsack - FPTAS
0/1 Knapsack: items w/ weight and value, capacity constraint, maximize total value. NP-hard. But has FPTAS (Fully Poly-Time Approximation Scheme)! PTAS: for any eps>0, runs in poly(n) time (but runtime may be exponential in 1/eps). FPTAS: for any eps>0, runs in poly(n, 1/eps) time.
5. Inapproximability
Some NP-hard problems don't admit good approx unless P=NP.
5.1 PCP Theorem
PCP Theorem (Arora, Safra, etc. 1992-93): NP = PCP(O(log n), O(1)). Meaning: every NP problem has a probabilistically checkable proof (PCP) that uses O(log n) random bits and reads O(1) bits of the proof, accepts correct proofs w/ prob 1, rejects incorrect proofs w/ prob >= 1/2. Why it matters for approx: implies MAX-3SAT (maximize satisfied clauses) has no (1-eps)-approx for some constant eps > 0 unless P=NP. I.e., you can't even get 99.9% of optimal efficiently! This was a HUGE result. Before PCP, inapproximability was proven case by case with ad-hoc reductions. PCP gives a unified framework.
5.2 Hastad's Results
Hastad 1997/2001 - tight inapproximability results via PCP:
- MAX-3SAT: inapprox to 7/8 + eps (randomized assignment achieves 7/8!!)
- MAX-CLIQUE: inapprox to n^{1-eps} for any eps (super-polynomial gap!)
- 3-coloring: NP-hard to color 3-colorable graph w/ 4 colors... actually I think it's k colors for any k >= 4? Check this.
5.3 Unique Games Conjecture (Khot 2002)
Conjectured: Unique label cover problem is NP-hard to approximate to any constant factor. Status: unproven. But IF true, gives tight inapprox results for many problems:
- Vertex cover: 2-eps hard
- Max-Cut: UGC implies Goemans-Williamson (.878-approx) is optimal
- Many constraint satisfaction problems Sub-exp time algorithms for unique games exist (Arora et al). UGC is very controversial. Some believe it's false.
6. Randomized Algorithms (brief)
6.1 MAX-CUT
Given undirected graph, find partition of V into S, V\S maximizing edges crossing the cut.
Randomized 1/2 approx: put each vertex in S independently w/ prob 1/2. E[cut edges] = |E|/2. OPT <= |E|. So E[alg] >= OPT/2. Goemans-Williamson 1995: .878 approx using semidefinite programming (SDP).
- Relax integer assignment (+/-1) to unit vectors in R^n
- Solve SDP for optimal vector assignment
- Round: pick random hyperplane, assign sides based on which side each vector falls on
- Analysis: prob edge cut = arccos(rho_{ij})/pi where rho is correlation. Expected value >= 0.878 * OPT. This was a breakthrough - first use of SDP for approx algorithms. GW bound is tight under UGC.
6.2 Randomized Rounding
Technique: solve LP relaxation (allow fractional solutions), round fractional solution to integer. Example: randomized rounding for set cover. LP relaxation: x_i in [0,1] instead of {0,1}. Solve LP. Round: include set i w/ prob min(1, cx_ilog(n)). With c large enough, expected cost = O(log n) * OPT_LP <= O(log n) * OPT. And w/ high prob all elements covered. Other rounding techniques: threshold rounding (x >= 1/2 -> round up), iterated rounding (round and reoptimize), pipage rounding (for submodular objectives). Key results to memorize for final: Cook-Levin (SAT NP-complete), standard reductions (3SAT->IS->VC- >Clique), VC 2-approx, Set Cover ln(n)-approx and matching lower bound, TSP inapprox in general, Christofides 3/2, Knapsack FPTAS, PCP theorem statement Also: know the difference between NP-hard and NP-complete, and why co-NP matters. Prof said this WILL be on the final.