CS 6515/4540 · Exam 3 study notes
109 problems (85 tied to a flagged insight) · 37 figures · 5 interactive widgets · 79 lecture insights · every number was computed by
src/calc.py, not by hand.0 · The exam: format, scope, and what's missing
0.1 The format, from this semester's real exams
Exams 1 and 2 of this semester (same instructors, Fall 2026) are now in the folder, and they agree with each other. That's much stronger evidence than the Unit 1 practice exam I used before. Exam 2 (Oct 27) ran 70 minutes, 100 points, two pages of notes, no calculator ⚑ Past exam / HW · I58 I59. Its Q1 (40 points) mixed select-ALL multiple choice (5–6 points each), one calculation (10 points), one short proof (6 points) and one “strongest bounds” question (8 points) ⚑ Past exam / HW · I60 I62. Then came three guided long questions (15 + 20 + 25 points). Each long question was a chain of hinted parts, where you “may use a stated claim from an earlier part”, ending with a small “construct an instance” part ⚑ Past exam / HW · I61 I65. Exam 1 (Sep 22) had the same 40 + 20 + 20 + 20 shape. (The older Unit 1 practice exam said one page and about 75 minutes ⚑ Flagged in lecture · I07 ⚑ Past exam / HW · I08. The real Exam 2 rules supersede it.)
The most useful fact: two of Exam 2's three long questions were Part 2 homework problems with the roles swapped. HW4 #18 hitting set with deterministic rounding became set cover with deterministic rounding, and HW4 #16 became the gradient-descent chain marked “(This was a homework problem!)” ⚑ Past exam / HW · I63 I64. So Exam 3's long questions will most likely re-skin HW5 (min cuts, MAX-E3SAT probabilistic method, randomized rounding + repetition, the repetition protocol) and HW6 (reductions). §15 trains exactly those re-skins, and the two mocks in §17 use the exact Exam 2 layout. The full evidence and question-type shares are in §2.2.
0.2 Scope: Unit 3 only, not cumulative
The exam covers randomization (Oct 29, Nov 3, Nov 5) and reductions (Nov 10, Nov 12). The Nov 17 lecture (approximation and hardness) is explicitly not on Exam 3 ⚑ Flagged in lecture · I01 I02. Nothing in the transcripts or slides says Exam 3 is cumulative. The cumulative remarks are about the final, which can replace an exam and will be curved. So Units 1–2 are out, except as tools (max-flow/min-cut and LPs are used here but not re-taught).
0.3 Materials: what's in, what's still missing
I used everything present: the five clean transcripts, the three extra OMS video transcripts (NP1, NP2, GR2), HW5, Exams 1–2 and the Exam 2 practice exam, the typed notes for Lec 16, 17 and 18, the handwritten boards for Lec 16, 17 and 19 (Nov 10), Mitzenmacher–Upfal, Kleinberg–Tardos, and the Unit 1 folder for style. Status of each item:
| Item | Status | What I did |
|---|---|---|
| Homework 5 (homeworks/hw5.pdf) | ✅ added, no official solutions (you are not submitting it) | §15: original wording + my full solutions in exam-answer form, plus ten fully solved exam-style re-skins. Drilled as timed exam questions, not write-ups. |
| Exams 1 and 2 (Fall 2026) + Exam 2 practice + solutions | ✅ added | Format and difficulty analysis (§2.2); mocks A and B copy the Exam 2 layout (§17); select-all drill (§16). |
| Part 2 HW3/HW4 (../algo-part2-notes/homeworks) | ✅ read for the HW → exam mapping only | Shows that Exam 2 re-skinned HW4 #16 and #18 (§2.2). |
| Unit 3 practice exam + solutions (Canvas) | ❌ still missing ⚑ Flagged in lecture · I04 | Do it timed when it appears. Ask me to run a coverage round against it. |
| Homework 6 (reductions, “practice for the exam”) | ⏳ not released yet. On Nov 10 the professor said HW6 “has reductions, as practice for the exam” ⚑ Flagged in lecture · I05 | Reductions drilled from the lecture ones (§10–§12, Mock A Q4, Mock B Q4). |
| OMS videos NP1, NP2, GR2 (extra-transcripts/) | ✅ added as extra | Used to enhance, never to override the lecture. Content from them carries a video tag: search problems and “in NP” proofs, MST/knapsack/knapsack-search (§9.2), NP-completeness and composition (§9.4), the full 2-SAT algorithm and its proof (§10.3), the general clause split and its size (§10.4), exact-4-SAT and stingy SAT (problems 10.10–10.12). Insights I70–I78. |
| DPV ch. 8, other OMS videos (NP3: graph problems, knapsack), Nov 12 board | ❌ still missing | KT ch. 8 used and labeled. The lecture covered the graph reductions, so NP3 isn't needed. |
MU numbering: the syllabus says MU 1.4 for min-cut. In your 2nd-edition PDF, min-cut is §1.5 (§1.4 is now the Naive Bayes classifier). I used MU §1.5. MU 6.1–6.4 match in both editions.
0.4 Study plan: Fri Nov 13 → Thu Nov 19, 3:30 PM (about 21.8 h total)
HW5 is the best predictor of the long questions, so it comes first, drilled as timed exam questions (you aren't submitting it, so no write-up time). Reductions (the strongest lecture signals) follow Mon–Tue. No day exceeds 3.7 h. About 68% of the time is retrieval (problems, HW, spaced review, mocks) and 27% is reading. That ratio is deliberate (§0.5). The minutes are summed by script from one plan table.
| Day | Blocks (in order) |
|---|---|
| Fri 13 205 min ≈ 3.4 h | Sleep first (it's 3:30 AM). Then: §1 + §2.2 skim, §3–§4 (Karger, boosting), §15.1
|
| Sat 14 220 min ≈ 3.7 h | §5–§6 (probabilistic method, rounding), §15.2–§15.3
|
| Sun 15 180 min ≈ 3.0 h | §15.4, §9 (P/NP, with the NP1 video additions)
|
| Mon 16 220 min ≈ 3.7 h | §10–§11 reductions (with the GR2/NP2 additions) + select-all drill
|
| Tue 17 200 min ≈ 3.3 h | §12 template, Mock A
|
| Wed 18 215 min ≈ 3.6 h | Mock B, note sheet, redo misses
|
| Thu 19 65 min ≈ 1.1 h | Light retrieval only; nothing new after noon; exam 3:30 PM
|
0.5 Why study this way (what the research says)
The plan and the layout of every section follow the techniques with the strongest evidence in learning research:
| Technique | Evidence | How these notes use it |
|---|---|---|
| Retrieval practice (testing yourself) | Rated “high utility” in Dunlosky et al.'s 2013 review of 10 techniques. In Roediger & Karpicke (2006), restudying won on an immediate test but tested students recalled more after 2 days and 1 week. | Every concept ends in ✍ problems. Solve on the iPad before opening the solution (feedback matters). Mocks at full length. |
| Spaced practice | Also “high utility” (Dunlosky et al.). Cepeda et al. (2008, 1,350+ people): the best gap between study and review is about 10–20% of the time until the test, for tests a few weeks out. | With the exam ~6 days away, the best gap is about 1 day. Every day starts with a Spaced review block on earlier ★ misses. |
| Interleaving (mixing problem types) | Rated “moderate utility” by Dunlosky et al. A math classroom RCT (Rohrer et al. 2020) found 61% vs 38% on a test a month later. A meta-analysis found g ≈ 0.34 for math. It helps you pick the right method, which is exactly what an exam with mixed questions tests. | Learn each topic blocked first (Fri–Mon), then switch to mixed sets: §16, the mocks, spaced reviews “in mixed order”. |
| Worked examples, then fading | The worked-example effect: novices learn more from studying solved examples. The expertise-reversal effect: the benefit disappears or reverses as you get better, so move to solving problems yourself. | Each concept has a worked example, then problems. First pass: study the example. Second pass (spaced reviews, mocks): no peeking. |
| Self-explanation | “Moderate utility” (Dunlosky et al.). | “How to read this figure” boxes and Trap boxes. Before opening a solution, say why each step holds. |
| Rereading, highlighting, summarizing | “Low utility” (Dunlosky et al.), even though they're the most popular. | Don't reread sections passively. If a section feels familiar, do its problems cold instead. |
| Sleep | Evidence is mostly correlational. All-nighters hurt complex tasks more than rote recall, and sleep supports consolidation. | No all-nighters, especially Wed night. Today: sleep first, it's 3:30 AM. |
Sources: APS summary of Dunlosky et al. 2013 · Roediger & Karpicke 2006 · Cepeda et al. 2008 · Rohrer et al. 2020 briefing · interleaving meta-analysis summary · expertise reversal · sleep and all-nighters. Effect sizes come from these summaries; I did not reread every primary paper.
0.6 Notation used throughout (read once, refer back)
The same letter means different things in different parts of the unit. This table is the fix.
| Symbol | Meaning | Where |
|---|---|---|
| n, m | Graphs: n = #vertices, m = #edges. Formulas: n = #variables, m = #clauses. Hitting set: n = universe size, m = #sets. | everywhere; check which! |
| Δ, λ | Δ = a fixed minimum cut (as a set of edges); λ = |Δ| = the min-cut size | §4, §15.1 |
| e₁, …, en−2 | the edges Karger contracts, in order | §4.2 |
| p, N, δ | p = one run's success probability; N = number of independent runs; δ = allowed failure probability | §4.3, §15 |
| A, B, C(A,B) | sides of a cut, and the set of crossing edges | §5 |
| Xₑ, Wⱼ, I | 0/1 indicators (edge e crosses, clause j satisfied, event happens) | §3.3, §5, §6 |
| Φk | E[final cut | placements of the first k vertices] | §5.3 |
| M*, OPT | the optimum (max satisfiable clauses, min cover size, …) | §6, §15.3 |
| yᵢ, zⱼ / ŷᵢ, ẑⱼ | ILP variables (variable i true, clause j counted) / their optimal LP (fractional) values | §6.3–6.4 |
| LP* | optimal LP value: ≥ OPT for maximization, ≤ OPT for minimization | §6, §15.3 |
| αₖ, βₖ | αₖ = 1 − 2−k (fair coins on a k-clause); βₖ = 1 − (1 − 1/k)k (LP rounding factor) | §6.5 |
| A → B, f, g | A reduces to B; f maps inputs of A to inputs of B; g maps solutions back | §9–§12 |
| Ĝ | complement graph (same vertices, flipped edges) | §11.2 |
| C(n,k) | “n choose k” = n!/(k!(n−k)!) | §3.2, §15.1 |
| α | overloaded: a constant in boosting (N = α·n(n−1)·ln n); the factor in “α-small cut”; “α-approximation”; and αₖ above. Read it from context. | §4.3, §6.1, §15.1 |
| M (in §15.3) | number of covering constraints (sets for hitting set, elements for set cover) | §15.3 |
| Cⱼ⁺, Cⱼ⁻ | indices of positive / negated variables in clause j | §6.3 |
1 · What the professor flagged
▸ Collapsed: click to expand▾ Click to collapse
Every exam-relevant remark I found after reading all five transcripts in full, plus the slides. Each has the exact quote (searchable in the source file), where it is, what it changes, and a link to where the notes cover it.
Colors: red edge = direct exam signal, purple edge = sources disagree, orange = emphasis, warning, or Q&A. The same list is in exam_insights.md.
From this semester's real exams: 70 minutes, two pages of notes, select-ALL multiple choice, and long questions that re-skin the homework. Exam 2 Q3/Q4 were HW4 #16/#18 (I63, I64). So HW5 is the long-question bank (§15).
Scope and logistics
“That is not going to be on Exam 3, because it's two days before the exam and it blends a couple of topics.”
“The exam content is randomization and this reduction business, plus the kind of conclusions we've drawn.”
“So you need to understand P, NP, and so on, and how reductions give information beyond "you're very hard" or "you're very easy."”
“I'll post the practice exam ahead of the exam so you have time to practice.”
“Yes, homework 6 has reductions, as practice for the exam.”
“I am putting a reduction on the final.”
“3.30, 3.35 and go on till 4.45.”
“Bringing one page of notes is permitted.”
Past exams and homework (evidence)
“Time: 70 minutes”
“Bringing two pages of notes is permitted.”
“Select ALL statements that are always true.”
“You may use a stated claim from an earlier part even if you did not prove it.”
“a counterexample suffices for a false statement.”
“(This was a homework problem!)”
“Hitting Set via Deterministic Rounding”
“Construct a family of graphs for which the algorithm can return an independent set of”
“Hint: Stop your watermelon earlier!”
“This problem walks you through another example of the use of randomized rounding.”
“Hint: this is the Probabilistic Method idea discussed in lecture.”
“Give an example of a graph G where the LP relaxation value is strictly more than the size of the maximum matching on G.”
“What are the strongest lower and upper bound on the size of the minimum vertex cover that follows from this information?”
Randomized algorithms: basics
“Question: Las Vegas or Monte Carlo? Do we always get a min-cut? No.”
“It's very easy to prove, one line (it's in the homework).”
“The first is very important (I put it in a box): linearity of expectation.”
“This is a great technique. Break random variables into simple random variables—for example, Bernoulli zero-one variables.”
“Important: the edge indicators are generally not independent. Linearity of expectation does not require independence.”
“Check for understanding. Suppose E[X] = 6 and X ≥ 0. What does Markov say about P(X ≥ 24)? Can it tell us P(X ≥ 4) is small?”
Karger's min-cut and boosting
“Let that sink in: the min-cut is preserved as long as we are lucky and contract edges not in the cut.”
“I call this the watermelon algorithm, for obvious reasons.”
“If the success probability of your randomized algorithm is at least p, where p⁻¹ is polynomial in the input size, then we can repeat polynomially many times and get probability of success 1 − o(1).”
“For now, we don't have the size of the min-cut. We don't have a way to verify that the outcome is a min-cut.”
“After N independent runs, the probability that we find a minimum cut is at least 1 − (1 − p)N .”
“gives P(all runs fail) ≤ (1 − p)N ≤ e−pN ≤ n−α .”
Probabilistic method and derandomization
“I will not prove this, because it's in your homework, but here is a big takeaway of the probabilistic method.”
“Here is the algorithmic scheme. First comes sampling.”
“This step in the lecture assumes m is even.”
“This derandomization is greedy.”
“All of you will produce a cut of size at least m/2, but it doesn't have to be the same cut.”
“you can find a small cut in a graph, but finding the largest cut can take us a long time.”
Randomized rounding (MAX-SAT)
“There's also a problem in the homework where you apply the same techniques to yet another problem.”
“The 7/8 result here is a guarantee for exactly three distinct literals per clause.”
“Håstad proved it's NP-hard to do better than 7/8.”
“taking the better bound separately for each clause does not by itself justify taking the better of two whole assignments.”
“The guarantee is in expectation; an individual run need not attain the bound.”
P, NP, and reductions
“(Maybe I'll ask this on the exam; I'm telling you before the other section.)”
“So it's not symmetric at all; that's a great multiple-choice question to think about.”
“A: No, no. They very much depend on A and B.”
“No, there's no other restriction, as long as you satisfy this if-and-only-if.”
“f must be connected to g in a very specific way: I need to be able to recover the solution at the end.”
“So knapsack, as we saw it in class, is not a search problem.”
“Important: they don't have to be search problems; they can be crazy problems, as long as everybody reduces to them.”
“A: We don't know yet how to solve them in polynomial time.”
“Two conclusions to make explicit in your notes.”
“the reduction in the other direction doesn't have to be the inverse operation.”
“I don't expect you to have an illumination during the exam or homework.”
SAT, 2-SAT, 3-SAT
“all literals in the same strongly connected component must get the same truth value.”
“you have to follow a certain order in the assignment (watch the video; it's not that important for this class)”
“But note that for a valid reduction we need the if-and-only-if: we have to check both directions.”
“Why not 2SAT? I need this intermediate structure”
Graph reductions
“1. Input transformation: transform an input of the first problem into an input of the second, in polynomial time.”
“Those two sentences are enough: linear in this, quadratic in that, therefore polynomial. Done.”
“we don't need super detailed proofs as long as we have the right ideas.”
“every time you see a variable and its negation, add an edge”
“For example, the contrapositive: instead of "if P then Q", prove "if not Q then not P".”
“in the other session I said this would be a great final exam question, as an LP question about the duality between independent set and vertex cover”
“Q: Is it always true that the complement of a vertex cover is an independent set?”
“do reductions preserve approximation factors?”
“if you reduce to a problem in P, your problem is in P.”
“if A is NP-hard and B is in P, then?”
“Think about this (for your own entertainment): if you have a way to answer "yes or no, is there an independent set of size k?", can you find the set?”
OMS videos NP1/NP2/GR2 (extra)
“Often they'll show the reduction in the other direction. That's not really proving anything.”
“normally, it's just going to take one or two sentences to show that a particular problem is in NP”
“So the best we can say is that, as far as we know right now knapsack is not known to be in the class NP.”
“The MST problem is in the class NP, and the MST problem is in the class P.”
“the important thing to remember is that NP does not stand for not polynomial time”
“we might create n new variables for each clause, so it has order nm variables in the worst-case”
“In problem 8.8, you consider exact 4-SAT.”
“if a set of vertices S is a sink SCC, then its compliment is a source SCC and vice versa”
“Eventually, I either end up with the empty formula which is satisfied, or I end up with a formula where all clauses are of size exactly 2”
2 · Coverage map and exam analysis
▸ Collapsed: click to expand (3 subsections)▾ Click to collapse
2.1 Every topic, where it comes from, how much it weighs
Weight is my estimate from the transcript signals (§1) and the time spent in lecture. H = expect a full question or several short ones, M = likely a short question or part of one, L = unlikely, know the idea. The HW5 column is the actual homework. HW6 isn't released, so “HW6” marks what the transcripts say it will contain. “Video” means the OMS NP1/NP2/GR2 transcripts (extra material).
| Topic | Lecture / video | Slides / board | Textbook | HW5 (actual) | Weight | Notes § |
|---|---|---|---|---|---|---|
| Las Vegas vs Monte Carlo | Oct 29 | Lec 16 typed §2, board p1 | MU 1.x intro | — | M | 3.1 |
| Bernoulli / binomial / geometric, expectation | Oct 29 | Lec 16 §3, board p1–2 | MU 2.1, 2.2, 2.4 | — | M | 3.2 |
| Linearity of expectation, indicator method | Oct 29, Nov 3, LP4 | Lec 16 §3.3, Lec 17 §2.1 | MU 2.1.1 | used everywhere | H | 3.3 |
| Markov's inequality (+ proof) | Oct 29 | Lec 16 §3.4, board p3 | MU 3.1 | proof is HW | M | 3.4 |
| Karger's contraction (watermelon) + analysis | Oct 29, Nov 3 recap | Lec 16 §4, board p3–5 | MU 1.5 | #19: count min cuts, α-small cuts | H | 4.1–4.2 |
| Boosting: 1 − (1 − p)N, choosing N | Nov 3 | Lec 17 §1, board p1–3 | MU 1.5 end | #21(d), #22(b–c) | H | 4.3 |
| Probabilistic method: E[X] = μ ⇒ both sides possible | Nov 3 | Lec 17 §2, board p3–4 | MU 6.2 (Lemma 6.2) | #20(b) | M | 5.1 |
| Max-cut ≥ m/2, Pr[X ≥ m/2] ≥ 1/(m/2+1) | Nov 3 | Lec 17 §2.1–2.2, board p4–5 | MU 6.2.1 | likely | H | 5.1–5.2 |
| Derandomization (conditional expectations) | Nov 3, LP4 §7 | Lec 17 §3, board p5–8 | MU 6.3 | likely | M–H | 5.3 |
| HW5-only techniques: early-stopped contraction, rounding + repetition, challenge protocols (zero knowledge) | — (HW5) | — | — | #19.2, #21(d–e), #22 | H | 15 |
| Union bound / Ramsey coloring; sample & modify | — (not in lecture) | — | MU 6.1, 6.4 | — | L | 5.4 |
| MAX-SAT fair coins ½, MAX-E3SAT 7/8 | LP4 §4–8 | Lec 18 §2, §4 | MU 6.2.2 | #20(a),(c) | H | 6.1–6.2 |
| ILP, LP relaxation, randomized rounding 1 − 1/e | LP4 §9–22 | Lec 18 §1, §3 | — | #21: hitting set + repetition | H | 6.3–6.4 |
| Best of two: ¾ | LP4 §23–24 | — | — | — | M | 6.5 |
| Bounds on OPT from a solution, a guarantee, an LP value (Q1(f) type) | (both real exams) | — | — | — | H | 6.6 |
| P, NP (search problems), NP-hard, NP-complete; “in NP” proofs; MST, knapsack, knapsack-search | Nov 10 (+ NP1 video) | board p1–3 | KT 8.3–8.4 | — | H | 9.1–9.2 |
| Reductions (f, g, ⇔), direction, transitivity | Nov 10 (+ NP1 video) | board p2 | KT 8.1 | HW6 | H | 9.3–9.4 |
| What reductions preserve (hard →, easy ←, P = NP) | Nov 12 | — | KT (8.1)–(8.2) | — | H | 9.5 |
| SAT, Cook–Levin (statement), Max-SAT is hard, ILP is hard | Nov 10, LP4 §10 | board p3 | KT 8.4 | — | H | 10.1–10.2 |
| 2-SAT ∈ P (implication graph, SCCs) | Nov 10 (+ GR2 video) | board p3–4 | — | — | M | 10.3 |
| 3-SAT NP-hard (clause splitting); exact-4-SAT, stingy SAT | Nov 10 (+ NP2 video) | board p4–5 | KT 8.4 (circuit route), DPV 8.3, 8.8 (named in NP2) | HW6 | H | 10.4 |
| 3-SAT → Independent Set | Nov 12 | (board missing) | KT 8.2 | HW6 | H | 11.1 |
| IS ↔ Clique, IS ↔ Vertex Cover | Nov 12 | (board missing) | KT 8.1 | HW6 | H | 11.2–11.3 |
| Approximation is not preserved | Nov 12 | — | — | — | M | 11.4 |
| Bipartite matching → max flow (easiness) | Nov 12 | — | KT (8.1) remark | — | M | 11.5 |
| Decision vs search, self-reducibility | Nov 12 (“for your own entertainment”) | — | KT 8.1 | — | L | 9.6 |
| Set Cover / Set Packing / Circuit-SAT | — | — | KT 8.1, 8.4 | — | L | 11.6 |
2.2 What this semester's exams teach about Exam 3 ⚑ Past exam / HW · I58 I60 I63 I65
Sources: Exam 1 Section A solutions (Sep 22), Exam 2 Sections A and B (identical) and the official solutions (Oct 27), the Exam 2 practice exam with solutions, HW4 (../algo-part2-notes) and HW5.
| Exam 2 part | Points | Type | Where it came from |
|---|---|---|---|
| Q1(a)(c) LP duality / Farkas | 5 + 6 | select-ALL multiple choice | lecture theorems (weak/strong duality, Farkas); the false options needed a counterexample |
| Q1(b) complementary slackness | 5 | select-one | lecture theorem |
| Q1(d) one projected gradient step | 10 | calculation on a given instance | lecture algorithm, by hand |
| Q1(e) first-order optimality | 6 | 3-line proof | lecture fact |
| Q1(f) bounds on OPT from a 2-approximation + a matching | 8 | “strongest bounds”, with a distractor | lecture guarantees; the matching info was useless (the trap) |
| Q2 greedy independent set (valid, Δ-approximation, tight family) | 15 | guided proof + construct | same genre as HW4 #17 (greedy load balancing), new problem; tight family = star |
| Q3 gradient-descent chain (3 hinted parts) | 20 | guided proof | HW4 #16 re-skinned; the hint says “(This was a homework problem!)” |
| Q4 set cover: ILP, threshold rounding at 1/k, k-approximation, tight instance | 25 (30 in the body) | guided proof + construct | HW4 #18 (hitting set, threshold 1/b) with the roles swapped; tight instance = three identical sets |
Shares on Exam 2: lecture facts as select-all/select-one 16%, a by-hand calculation 10%, short lecture proofs 6%, bounds reasoning 8%, homework re-skins 45% (Q3 + Q4), a same-genre new problem 15% (Q2). Exam 1 had the same skeleton: 40 points of short answer (guided induction, a recurrence, approximation bounds “80 ≤ OPT ≤ 100”, an MDP computation, a cut certificate, a counterexample, median-of-medians fractions, residual capacities), then three 20-point guided problems built on lecture algorithms. The Exam 2 practice exam matched the real one in shape (an LP formulation, an integrality gap “give an example”, a guided convexity chain), not in content.
2.3 The Unit 1 practice exam (older evidence)
The only past exam available is the Unit 1 practice exam (Fall 2025, 100 points). Classifying each part by where it came from:
| Part | Points | Type | Reused from |
|---|---|---|---|
| §1 short answer (7 × 5) | 35 | T/F or one-line fact + 1–2 line justification | Lecture facts (“As discussed in class, 3 does not work”), definitions (PTAS), and a small MDP computation |
| §2 flow (residual graph, augmenting path, max-flow value, min cut) | 20 | Run a lecture algorithm on a given example | Lecture example type (Ford–Fulkerson by hand) |
| §3.1–3.2 inversion counting (MergeAndCount + recursion) | 15 | Design + describe | Classic textbook / lecture problem |
| §3.3 prove T(n) = O(n log n) by induction | 10 | Reproduce a lecture proof | The official solution says only “See handwritten notes from Lec 2” |
| §4 knapsack DP (table, recurrence + correctness, runtime + pseudo-poly) | 20 | Design + correctness + runtime analysis | The lecture's knapsack DP, almost verbatim |
Shares: lecture facts and definitions 35%, running a lecture algorithm on an example 20%, reproducing a lecture proof 10%, design and correctness of a lecture-style algorithm 28%, runtime analysis 7%. Almost everything was a lecture example, a lecture proof, or a lecture algorithm. Nothing needed a new idea. The answer format is short prose, with the key step justified in a sentence.
3 · Probability toolkit and the two kinds of randomized algorithms
Oct 29 lecture · Lec 16 typed notes + board · MU 2.1, 2.2, 2.4, 3.1. You only need a handful of tools. The professor: “We don't need a lot of probability. Mostly it's a couple of tools.”
- classify an algorithm as Las Vegas or Monte Carlo, with a one-line reason
- compute Bernoulli/binomial/geometric probabilities and means by hand
- compute an expectation by writing a count as a sum of indicators
- state and prove Markov's inequality, and say when it is useless
- write a product of conditional probabilities (chain rule)
3.1 Las Vegas vs Monte Carlo ⚑ Flagged in lecture · I09
Why it exists. Randomness can make an algorithm simpler or faster, but you pay somewhere. Either the answer may be wrong, or the running time becomes random. The two names say which one you're paying with, and they decide what you analyze.
Mechanism. A Las Vegas algorithm always returns a correct answer. Its running time is a random variable, and we analyze its expected running time (“average case”). Randomized Quicksort is the example: every pivot sequence sorts correctly, and only the number of comparisons changes (worst n², average about 2n log n). A Monte Carlo algorithm has a bounded running time but may be wrong. It is correct with some probability p, and we analyze p. Examples: Fermat's primality test (one-sided error: primes are always called prime, some composites slip through) and Karger's contraction (always returns a cut, maybe not a minimum one). One-sided vs two-sided error (for yes/no Monte Carlo algorithms): one-sided means one kind of answer is always right, as in Fermat (“composite” is always correct, “prime” may be wrong) or a verifier that never rejects an honest prover (§15.4). Two-sided means it can err on both kinds of input. One-sided error is what makes “repeat and reject if any run rejects” work. The typed notes add a subtlety: these are paradigms, “not a claim that every randomized algorithm fits neatly into exactly one box.”
- “Monte Carlo = sometimes slow” is wrong. Monte Carlo's time is bounded; its answer may be wrong.
- The probability is over the algorithm's own coins, on a fixed (worst-case) input. It is not over random inputs (Lec 16 typed notes).
- Karger is Monte Carlo even though boosting makes failure tiny. “Tiny” isn't “never”.
- Randomized Quicksort (random pivots).
- Fermat's test: pick random a, answer “prime” iff ap−1 ≡ 1 (mod p).
- Karger's contraction algorithm (one run).
- Repeat “random cut; if it has ≥ m/2 edges, output it” until it outputs.
- Fair-coin assignment for MAX-SAT, output whatever you get.
Show solution
- Las Vegas. Every pivot sequence sorts correctly; only the number of comparisons is random (average O(n log n), worst n²).
- Monte Carlo with one-sided error: a prime is always classified correctly, but a composite can pass (remainder 1) and be wrongly called prime.
- Monte Carlo. It always returns a cut in n − 2 contractions, but contracting a min-cut edge early destroys that cut. Success probability ≥ 2/(n(n−1)).
- Las Vegas (MU §6.2.1): the output is checked (count crossing edges in poly time), so it is always correct; the number of rounds is geometric with mean 1/p ≤ m/2 + 1.
- Monte Carlo, and in fact only an expectation guarantee: E[#satisfied] ≥ m/2, but one run can be worse.
3.2 Random variables, three distributions, expectation
Why. Each distribution encodes a story that keeps showing up in algorithm design. The professor's advice: think about the story, then translate it into the math.
Mechanism. A random variable X maps outcomes to numbers. In the discrete case it is described by Pr[X = x] ≥ 0, with these summing to 1. Bernoulli(p), one experiment: Pr[X = 1] = p, Pr[X = 0] = 1 − p. Binomial(n, p), count successes in n independent trials: X = X₁ + ⋯ + Xₙ with Xᵢ ~ Ber(p) and Pr[X = k] = C(n,k)pk(1−p)n−k, range {0, …, n}. Geometric(p), repeat until the first success: Pr[X = k] = (1−p)k−1p, range {1, 2, …}. Expectation E[X] = Σₓ x·Pr[X = x] is the probability-weighted average. Known means (MU): E[Ber] = p, E[Bin] = np, E[Geo] = 1/p.
- X = number of successes in 4 trials. Compute Pr[X = 2], Pr[X = 0], and E[X].
- Y = number of trials until the first success. Compute Pr[Y = 3], Pr[Y > 3], and E[Y].
- Which of X, Y describes “run Karger until the first success”?
Show solution
- X ~ Bin(4, 1/4): Pr[X = 2] = C(4,2)(1/4)²(3/4)² = 27/128. Pr[X = 0] = (3/4)⁴ = 81/256. E[X] = np = 1 (linearity over 4 indicators, each with expectation 1/4).
- Y ~ Geo(1/4): Pr[Y = 3] = (3/4)²(1/4) = 9/64. Pr[Y > 3] = all three first trials fail = (3/4)³ = 27/64. E[Y] = 1/p = 4 (MU Lemma 2.9 / memoryless argument).
- Y, the geometric one: “repeat until success”. This is exactly why Pr[success within N runs] = Pr[Y ≤ N] = 1 − (1 − p)N.
- For X ~ Geo(p), show Pr[X = n + k | X > k] = Pr[X = n] (memoryless).
- Each cereal box holds one of n coupon types, uniformly at random. Use linearity and geometric expectations to find E[# boxes to collect all n]. Evaluate for n = 5 and n = 10.
Show solution
- Pr[X = n + k | X > k] = (1−p)n+k−1p / (1−p)k = (1−p)n−1p = Pr[X = n]. Past failures don't change the future.
- Let Xᵢ be the boxes bought while holding exactly i − 1 types. A new type appears with probability pᵢ = (n − i + 1)/n, so Xᵢ ~ Geo(pᵢ) and E[Xᵢ] = n/(n − i + 1). Linearity: E[X] = Σ n/(n−i+1) = n·H(n) = n ln n + Θ(n). n = 5: 137/12 ≈ 11.42. n = 10: ≈ 29.29 (compare n ln n = 23.03).
3.3 Linearity of expectation and the indicator method ⚑ Flagged in lecture · I11 I12 I13
Why. Most quantities we care about (cut size, number of satisfied clauses) have messy distributions because the parts interact. Linearity lets you ignore the interaction completely. The professor boxed it as “very important”.
Mechanism. E[X + Y] = E[X] + E[Y] for any random variables with finite expectations, dependent or not. The recipe used in this unit:
1. Write the quantity as a sum of 0/1 indicators: X = Σitems Iitem, where I = 1 if that item “counts” (edge crosses, clause satisfied).
2. E[I] = 1·Pr[I = 1] + 0·Pr[I = 0] = Pr[I = 1]. Compute one probability per item, in isolation.
3. Add: E[X] = Σ Pr[item counts].
Where linearity comes from (the professor's Riemann-sum aside): expectation is an “integral” (a weighted sum), and integrals are linear.
- No independence needed. The edge indicators of a random cut are dependent (in a triangle, 0 or 2 edges cross, never 3), and linearity still holds (Lec 17 typed notes).
- Independence is needed for products: Pr[all k literals false] = ∏ Pr[literal false] uses independence of distinct variables.
- E[max(A, B)] ≠ max(E[A], E[B]) in general. That's why the ¾ proof averages (§6.5).
Show solution
Write X = X₁ + ⋯ + Xₙ where Xᵢ = 1 if toss i is heads, else 0. Each Xᵢ is Bernoulli, so E[Xᵢ] = 1·Pr[Xᵢ = 1] + 0 = 1/2. By linearity of expectation (no independence needed), E[X] = Σ E[Xᵢ] = n/2.
For Bin(n, p) the same decomposition gives E[Xᵢ] = p, so E[X] = np. Compare MU §2.2, where the direct computation from the pmf takes a page.
Show solution
E[X] = 50, so (E[X])² = 2500. E[X²] = (1/99)Σi² = 9950/3 ≈ 3316.67 > 2500. In general E[X²] − (E[X])² = E[(X − E[X])²] ≥ 0. Jensen: for convex f, E[f(X)] ≥ f(E[X]). (f(x) = x² is convex.) The trap: E[X²] ≠ (E[X])², whereas linearity only covers sums and constant multiples.
3.4 Markov's inequality ⚑ Flagged in lecture · I10 I14
Why. An expectation alone doesn't tell you how likely a bad run is. Markov turns “average is small” into “a much larger value is unlikely”, using only E[X] and X ≥ 0.
Statement. If X ≥ 0 and a > 0, then Pr[X ≥ a] ≤ E[X]/a.
Proof (one line, MU Thm 3.1). Let I = 1 if X ≥ a, else 0. Since X ≥ 0, I ≤ X/a always: when I = 1, X/a ≥ 1, and when I = 0, X/a ≥ 0. Taking expectations, Pr[X ≥ a] = E[I] ≤ E[X]/a. ∎
Show solution
Markov: P(X ≥ 24) ≤ E[X]/24 = 6/24 = 1/4.
For a = 4 the bound is 6/4 = 3/2 > 1, which says nothing (every probability is ≤ 1). Markov is only useful for thresholds well above the mean. It can never show that the variable is unlikely to be near or below its mean.
Show solution
Let I be the indicator of the event {X ≥ a}. Then I ≤ X/a pointwise: if X ≥ a then I = 1 ≤ X/a; otherwise I = 0 ≤ X/a because X ≥ 0. Taking expectations (expectation preserves ≤), Pr[X ≥ a] = E[I] ≤ E[X/a] = E[X]/a. ∎
Where X ≥ 0 was used: the case I = 0. Without it, X/a could be negative and the pointwise inequality fails.
- If E[X] = n log n, bound Pr[X ≥ 10 n log n].
- If instead E[X] = 2 n ln n, bound Pr[X ≥ 10 n ln n].
- Does (a) say that Quicksort is O(n log n) in the worst case?
Show solution
- Markov: ≤ (n log n)/(10 n log n) = 1/10.
- ≤ (2 n ln n)/(10 n ln n) = 1/5.
- No. The worst case is still n². Markov only says the probability of a run 10× slower than average is at most 1/10. That's the trade-off the professor stressed: “you can say something meaningful but not exact.”
3.5 Conditional probability and the chain rule
Why. Karger's analysis asks “what is the chance the k-th step is good, given that all earlier steps were good?” The only tool is the chain rule.
Mechanism. Pr[A | B] = Pr[A ∩ B]/Pr[B]. For events E₁, …, Et: Pr[E₁ ∩ ⋯ ∩ Et] = Pr[E₁]·Pr[E₂ | E₁]·Pr[E₃ | E₁ ∩ E₂] ⋯ Pr[Et | E₁ ∩ ⋯ ∩ Et−1] (MU §1.5 uses this as Pr(Fn−2)). The professor's reason for conditioning only on the good past: “If the first one was in the min-cut, I broke it… so I only analyze the case where the past is good.”
- Complement: Pr[not A] = 1 − Pr[A]. (“Success” = 1 − Pr[all runs fail].)
- Independent events multiply: Pr[A ∩ B] = Pr[A]·Pr[B]. (N independent runs all fail: (1 − p)N; all k literals false: ∏(1 − pᵣ).)
- Disjoint events add: Pr[A₁ ∪ ⋯ ∪ At] = Σ Pr[Aᵢ] ≤ 1. (Counting min cuts, §15.1: one run returns one cut.)
- Union bound (any events, no independence needed): Pr[A₁ ∪ ⋯ ∪ At] ≤ Σ Pr[Aᵢ]. (“Some constraint is still uncovered” ≤ M·e−t, §15.3.) The same bound follows from Markov: Pr[X ≥ 1] ≤ E[X] for a count X.
- Linearity of expectation E[X + Y] = E[X] + E[Y] requires X and Y to be independent.
- Markov's inequality applies to every random variable with finite expectation.
- For a 0/1 random variable I, E[I] = Pr[I = 1].
- The probabilities in randomized-algorithm guarantees are taken over a random input distribution.
- A Monte Carlo algorithm has a bounded running time but may output a wrong answer.
- If X ~ Geo(p), then E[X] = 1/p.
For each: True or False, with a 1–2 line justification (Unit 1 exam format).
Show solution
- False. Linearity holds for any random variables, even dependent ones (Lec 16/17: “independence is not required”). The max-cut edge indicators are dependent, and linearity still applies.
- False. It needs X ≥ 0. Counterexample: X = −1 or +1 with probability ½ each, a = 1: Pr[X ≥ 1] = ½, but E[X]/a = 0.
- True. E[I] = 1·Pr[I=1] + 0·Pr[I=0]. This is the step behind every “E[Xₑ] = Pr[e crosses]”.
- False. Lec 16 typed notes: “The guarantees are always taken over the algorithm's random choices, not over a presumed random input distribution.” The input is fixed and worst case.
- True. Definition on the Lec 16 typed notes (Karger is the example).
- True. MU Lemma 2.9: E[X] = Σᵢ Pr[X ≥ i] = Σᵢ (1−p)i−1 = 1/p.
Linearity of expectation: does it need independence?
Markov: hypotheses and statement?
E[Geo(p)] and its story?
Why is Karger Monte Carlo and Quicksort Las Vegas?
4 · Karger's min-cut (the “watermelon algorithm”) and boosting
Oct 29 + Nov 3 lectures · Lec 16 §4 and Lec 17 §1 typed notes · boards · MU §1.5. This was derived live on the board and recapped in the next lecture, so expect to reproduce it ⚑ Flagged in lecture · I15 I16.
- run the contraction algorithm by hand and explain why parallel edges stay
- reproduce the 2/(n(n−1)) proof: preservation, degree bound, telescoping product
- choose N to boost success to 1 − δ and explain why we keep the smallest cut
4.1 The algorithm
Definitions. A cut of a connected graph G = (V, E) is a split of V into two nonempty sides (S, V∖S). Its size is the number of edges with one endpoint on each side. The global min cut minimizes that size over all splits; its size is called λ (lambda). Unlike Unit 2, there is no source s or sink t. A multigraph is a graph that may have several parallel edges between the same two vertices. Contraction creates them, and each copy counts as a separate edge.
Why it exists. Global min-cut (no source or sink, unit capacities) can be solved deterministically by running max-flow for every pair (s, t) and keeping the best: the global min cut separates some pair. That's correct but slow. Karger's idea is much simpler: an edge chosen uniformly at random is unlikely to be one of the few min-cut edges, so merge its endpoints and keep going. The professor named it the watermelon algorithm because the final picture is two big blobs with a bundle of edges between them. An exam may use that name.
while |V| > 2:
pick an edge e uniformly at random (parallel copies count separately)
contract e: merge its endpoints, delete self-loops, KEEP parallel edges
return the edges between the two remaining supervertices
4.2 Why one run succeeds with probability ≥ 2/(n(n−1))
Intuition. Early on there are many edges and few of them are in the min cut Δ, so you're almost surely safe. Near the end few edges are left, and “you need to get really lucky”. The proof quantifies this step by step and gets rid of the unknown |Δ| with a degree argument.
Claim 1 (preservation). If e ∉ Δ, then Δ is still a min cut of G/e. Every edge of Δ survives, and a cut of G/e is a cut of G, so nothing smaller appears. Hence, if no Δ-edge is ever contracted, the algorithm returns exactly Δ.
Step probabilities. Let e₁, …, en−2 be the contracted edges (random variables). Pr[e₁ ∉ Δ] = (|E| − |Δ|)/|E| = 1 − |Δ|/|E|. Given e₁, …, ek−1 ∉ Δ, all of Δ is still present. If the current graph has Ek edges, then Pr[ek ∉ Δ | past good] = 1 − |Δ|/Ek. (The board writes Ek = |E| − k + 1. Deleting self-loops can only make Ek smaller, so the safe route is to bound |Δ|/Ek using degrees, as next.)
Claim 2 (degree bound). deg(v) ≥ |Δ| for every vertex v of every intermediate graph (while Δ survives): ({v}, rest) is a cut of size deg(v), and Δ is minimum. Summing degrees counts each edge twice: 2Ek = Σ deg(v) ≥ |Δ|·(number of vertices) = |Δ|(n − k + 1). So |Δ|/Ek ≤ 2/(n − k + 1). Δ has disappeared from the bound.
Chain rule + telescoping. Pr[success] = ∏k=1n−2 Pr[ek ∉ Δ | e₁…ek−1 ∉ Δ] ≥ ∏k=1n−2 (1 − 2/(n−k+1)) = ∏ (n−k−1)/(n−k+1) = (n−2)/n · (n−3)/(n−1) · (n−4)/(n−2) ⋯ 2/4 · 1/3. Each numerator cancels the denominator two steps later. The last two numerators (2·1) and the first two denominators (n(n−1)) survive: Pr[success] ≥ 2/(n(n−1)) ≈ 2/n². For n = 6 the factors are 4/6 · 3/5 · 2/4 · 1/3 = 1/15. ∎
- The bound is for one fixed min cut Δ. Graphs can have several. Pr[return some min cut] can be larger.
- Write the probabilities as conditional on the good past. The steps are not independent.
- Get the direction of the inequality flip right: |Δ|/Ek ≤ 2/(#vertices) ⇒ 1 − |Δ|/Ek ≥ 1 − 2/(#vertices).
- There are n − 2 factors (from n vertices down to 2), not n.
- What is the probability that the first contraction avoids Δ? Compare it with the bound 1 − 2/n used in the proof.
- Check the degree bound deg(v) ≥ |Δ| for every vertex.
- State the theorem's lower bound on Pr[return Δ]. The exact value (computed by enumerating all runs) is 6/35. Is that consistent?
- Why is Pr[return some min cut] (19/35) larger?
Show solution
- (m − |Δ|)/m = 6/8 = 3/4. The proof uses |Δ|/|E| ≤ 2/|V|, giving ≥ 1 − 2/6 = 2/3. The true value is larger, as it should be (the bound is worst case).
- deg(1)=2, deg(2)=3, deg(3)=3, deg(4)=3, deg(5)=3, deg(6)=2, all ≥ 2 = |Δ|. (Each vertex alone is a cut, so its degree is at least the min-cut size.)
- 2/(n(n−1)) = 2/30 = 1/15 ≈ 0.0667. The exact 6/35 ≈ 0.1714 is above it. Consistent.
- This graph has 3 min cuts ({1}|rest, {6}|rest, {1,2,3}|{4,5,6}). Returning any of them counts as success, so the probability adds over the disjoint events. The theorem is about one fixed Δ.
Show solution
Preservation. If the algorithm never contracts an edge of Δ, the final two supervertices are exactly the two sides of Δ, so it returns Δ. (Contracting an edge not in Δ keeps Δ a min cut of the contracted graph: every edge of Δ survives and contraction creates no smaller cut.)
Step probabilities. Let e₁, …, en−2 be the contracted edges. Before step k (given e₁, …, ek−1 ∉ Δ) the graph has n − k + 1 vertices, all of Δ, and Ek edges, so Pr[ek ∉ Δ | past good] = 1 − |Δ|/Ek.
Degree bound. In the current graph each vertex v alone is a cut of size deg(v), so deg(v) ≥ |Δ|. Summing, 2Ek = Σ deg(v) ≥ |Δ|(n − k + 1), i.e. |Δ|/Ek ≤ 2/(n − k + 1).
Chain rule and telescoping. Pr[success] = ∏k=1n−2 Pr[ek ∉ Δ | past good] ≥ ∏ (1 − 2/(n−k+1)) = ∏ (n−k−1)/(n−k+1) = (n−2)/n · (n−3)/(n−1) · (n−4)/(n−2) ⋯ 2/4 · 1/3 = 2·1/(n(n−1)). ∎
Show solution
(1) The output must be a real cut of G. The edges between the final two supervertices are exactly the original edges crossing that partition. Merging parallel copies would undercount the cut's size, and we'd compare wrong sizes across runs.
(2) The probability analysis counts them. “Uniformly at random” is over current edges with multiplicity, and the degree bound 2|E| = Σ deg(v) ≥ |Δ|·|V| needs deg(v) to count every surviving original edge. With parallel copies merged, a min-cut edge could be chosen with higher probability than the bound allows.
- How many min cuts does C₅ have? Compare Pr[return a fixed one] with 2/(n(n−1)).
- Using only the theorem, show that every graph has at most n(n−1)/2 minimum cuts.
Show solution
- C(5,2) = 10 min cuts. Full enumeration gives each probability exactly 1/10 = 2/(5·4) = 1/10, so the theorem is tight here. The 10 probabilities sum to 1.
- For distinct min cuts Δ₁, …, Δt, the events “the run returns Δᵢ” are disjoint, and each has probability ≥ 2/(n(n−1)). Their total is ≤ 1, so t ≤ n(n−1)/2.
4.3 Boosting the probability of success ⚑ Flagged in lecture · I17 I18 I19 I20
Why. A student asked on Piazza why we care about a one-in-a-million success chance (n = 1000: p = 1/499500). Because each run is polynomial time, we can afford many independent runs, and failures multiply.
Keep the smallest, don't “stop at success”. We can't recognize a min cut, since we don't know its size. So run N times and keep the smallest cut. If any run produced a min cut, the kept cut is one. Cut sizes are easy to compare even though minimality can't be certified.
Claim. Pr[success] ≥ 1 − (1 − p)N. All N independent runs fail with probability ≤ (1 − p)N. (The lecture phrases it as Pr[X ≤ N] for X ~ Geo(p): Σk=1N p(1−p)k−1 = 1 − (1−p)N.)
Choosing N. Use 1 − x ≤ e−x: (1 − p)N ≤ e−pN. With N = α·n(n−1)·ln n and p = 2/(n(n−1)), pN = 2α ln n, so failure ≤ n−2α (lecture/board). The typed notes use N = ⌈α·n(n−1)/2·ln n⌉ and failure ≤ n−α. MU uses n(n−1)·ln n and failure ≤ 1/n². Same computation, different constants. Pick one and be consistent.
General principle (headline). If one run succeeds with probability ≥ p and p⁻¹ is polynomial in the input size, then O(p⁻¹ log(1/δ)) runs make the failure probability ≤ δ, so polynomially many runs give success 1 − o(1). If p = ½, two runs already give ¾.
Running time (derived, the lecture only says “polynomial”). Keep an n × n matrix of edge multiplicities. A contraction merges two rows and columns in O(n), and a random edge can be drawn in O(n) (pick a row in proportion to its degree, then a column in proportion to the multiplicity). One run = n − 2 contractions = O(n²). With n(n−1) ln n runs: O(n⁴ log n) total.
- The handwritten board wrote 1 − (1 − p)N+1. It's N: N runs fail together with probability (1 − p)N ⚑ Flagged in lecture · I19.
- Boosting needs p⁻¹ polynomial. With p = 2−n you'd need exponentially many runs.
- “With high probability” is not “always”. Boosted Karger is still Monte Carlo.
- Runs must be independent (fresh coins each time).
- Compute p.
- Lower-bound the success probability after N = 45 and after N = 100 independent runs (keeping the smallest cut).
- Give a number of runs that guarantees success ≥ 0.99, using (1 − p)N ≤ e−pN.
Show solution
- p = 2/90 = 1/45.
- 1 − (1 − p)N: N = 45 gives ≥ 0.6362 (about 1 − 1/e, since N = 1/p); N = 100 gives ≥ 0.8943.
- Need e−pN ≤ 0.01, i.e. N ≥ ln(100)/p = 45·ln 100, so N = 208 suffices. (The smallest N with (1 − p)N ≤ 0.01 is 205; either answer is fine if justified.) By hand: ln 100 ≈ 4.6, and 45 × 4.6 ≈ 207.
- Show that N = α·n(n−1)·ln n runs give failure ≤ n−2α. Evaluate for α = 1.
- The typed notes use N = ⌈α·n(n−1)/2·ln n⌉ and get failure ≤ n−α. Reconcile the two.
- How many runs is that, and is it polynomial?
Show solution
- (1 − p)N ≤ e−pN = e−(2/(n(n−1)))·α n(n−1) ln n = e−2α ln n = n−2α. For α = 1 that is 1.000×10-6: success ≥ 1 − one in a million.
- Same computation with half as many runs: pN = α ln n, so the failure bound is n−α. The constant in N just moves into the exponent.
- About n(n−1) ln n = 6,900,848 runs (board version, α = 1), each O(n²)-ish. That's O(n² log n) runs: polynomial.
Show solution
Failure after N trials ≤ (1 − 1/n²)N ≤ e−N/n². We need e−N/n² ≤ n−3 ⇔ N/n² ≥ 3 ln n ⇔ N ≥ 3n² ln n. So O(n² log n) repetitions. (E.g. n = 10: 691 runs; n = 100: 138,156.) This matches the typed notes' general rule O(p−1 log(1/δ)) with p = n−2, δ = n−3.
Show solution
We can't recognize success: given a cut, we can't check that it's minimum without already knowing the min-cut size, which is the thing we're computing. Instead, run N independent times and keep the smallest cut found. If any run produces a min cut, the kept one is a min cut, so Pr[success] ≥ 1 − (1 − p)N. What makes it work: the size of a cut is easy to compute, so we can compare candidates by objective value even though we can't certify optimality (Lec 17 typed notes: “We need not know which trial succeeded if we can select the best candidate by its objective value”).
- The watermelon algorithm is a Las Vegas algorithm.
- If an algorithm succeeds with probability p = 1/n⁵ and runs in polynomial time, polynomially many repetitions give success probability 1 − o(1).
- If an algorithm succeeds with probability 2−n, repeating it polynomially many times gives success 1 − o(1).
- Repeating Karger n(n−1) ln n times and keeping the smallest cut always returns a minimum cut.
- In Karger's analysis, the probability that the k-th contraction avoids Δ (given the past was good) gets smaller as k grows.
- Global min-cut can also be solved deterministically in polynomial time.
For each: True or False, with a 1–2 line justification (Unit 1 exam format).
Show solution
- False. Monte Carlo: it may return a non-minimum cut. Its running time is fixed (n − 2 contractions).
- True. p⁻¹ = n⁵ is polynomial; N = n⁵·c·ln n runs give failure ≤ n−c (the boosting principle).
- False. You'd need about 2ⁿ runs to make (1 − 2−n)N small. That isn't polynomial.
- False. Failure probability ≤ 1/n², not 0: it's “with high probability”, not “always”.
- True. The bound 1 − 2/(n−k+1) shrinks as fewer vertices remain. The professor: “at the end you need to get really lucky.”
- True. The lecture's slow method: run max-flow for every pair (s, t) and keep the smallest min s–t cut, since the global min cut separates some pair.
The three steps of the Karger proof?
Success after N runs?
Runs to get failure ≤ δ?
Why can't we stop at the first success?
5 · The probabilistic method and derandomization
Nov 3 lecture (recorded video) · Lec 17 typed notes §2–3 + board pp. 3–8 · MU 6.1–6.4
- prove E[X] = μ ⇒ Pr[X ≥ μ] > 0
- show every graph has a cut ≥ m/2 and turn it into Pr[X ≥ m/2] ≥ 1/(m/2+1)
- run the greedy derandomization (conditional expectations) and justify Φ never decreases
5.1 The probabilistic method: positive probability ⇒ existence ⚑ Flagged in lecture · I21 I26
Why. Sometimes we can't construct a good object directly but can show a random one is good with positive probability. Then a good one must exist (MU: “if there is a positive probability of winning a million-dollar prize in a raffle, then there must be at least one raffle ticket that wins”). Two forms appear in lecture: (1) Pr[random object has the property] > 0, and (2) the expectation form: if E[X] = μ then Pr[X ≥ μ] > 0 and Pr[X ≤ μ] > 0.
Proof of the expectation form (MU Lemma 6.2; this is homework). If Pr[X ≥ μ] = 0, every value with positive probability is < μ, so μ = Σ x·Pr[X = x] < μ·Σ Pr[X = x] = μ, a contradiction. Symmetric for Pr[X ≤ μ] = 0. ∎
First application: every graph has a cut with ≥ m/2 edges. Put each vertex in A or B by an independent fair coin. An edge uv crosses iff its endpoints get different sides, which happens with probability ½. With indicators Xₑ and linearity, E[|C(A,B)|] = Σₑ ½ = m/2. So some cut has ≥ m/2 edges. Since OPT ≤ m, a random cut is an expected ½-approximation for Max-Cut, which is NP-hard (MU §6.2.1): “you can find a small cut in a graph, but finding the largest cut can take us a long time.”
Show solution
Suppose Pr[X ≥ μ] = 0. Then every value with positive probability is < μ, so μ = E[X] = Σx<μ x·Pr[X = x] < Σx<μ μ·Pr[X = x] = μ, a contradiction. (The strict inequality holds because the probabilities sum to 1, so some term has positive probability.) The case Pr[X ≤ μ] = 0 is symmetric: all mass is > μ, giving μ > μ. ∎
Use: “some outcome achieves at least the average”, so an object with value ≥ μ exists.
- Show that each edge crosses with probability 1/2.
- Show E[|C(A,B)|] = m/2.
- Conclude that every graph has a cut with at least m/2 edges, and that this gives an expected ½-approximation for Max-Cut.
Show solution
- Edge uv: condition on u's side; v independently lands on the other side with probability ½. (Equivalently, 2 of the 4 equally likely outcomes split u and v.)
- Let Xₑ be the indicator of e crossing, so |C(A,B)| = Σₑ Xₑ. By linearity (the Xₑ are not independent, and that doesn't matter), E = Σₑ Pr[Xₑ = 1] = m/2.
- By the probabilistic method (5.1), Pr[|C| ≥ m/2] > 0, so such a cut exists. Since OPT ≤ m, a random cut has expected size m/2 ≥ OPT/2.
Show solution
In a triangle, if two edges cross then the third cannot: two vertices are on one side and the third on the other, so exactly 0 or 2 edges cross. So Pr[all three cross] = 0 ≠ (½)³. The exact distribution is Pr[X=0] = 1/4, Pr[X=2] = 3/4, with E[X] = 3/2 = 3·½, as linearity predicts. Linearity adds expectations of any random variables; independence would be needed only for products.
Show solution
Random assignment: a clause with kⱼ ≥ k distinct literals fails only if all its literals are false, with probability 2−kⱼ ≤ 2−k. By linearity, E[#satisfied] ≥ m(1 − 2−k), and by the expectation argument some assignment achieves at least that. For m = 40, k = 3: ≥ 35 clauses.
5.2 From expectation to a probability: then boost ⚑ Flagged in lecture · I22 I23
Why. The algorithmic scheme from lecture is sampling (success probability p > 0) followed by boosting (repeat about 1/p times). The expectation argument gives E[X] but not p. We need a lower bound on p = Pr[X ≥ m/2] whose inverse is polynomial.
m/2 = E[X] = Σi<m/2 i·Pr[X=i] + Σi≥m/2 i·Pr[X=i]. In the first sum every i ≤ ⌈m/2⌉ − 1; in the second every i ≤ m (all edges cross). Replace each i by those maxima and use Σi<m/2 Pr = 1 − p, Σi≥m/2 Pr = p (disjoint events): m/2 ≤ (⌈m/2⌉ − 1)(1 − p) + m·p. For even m: m/2 ≤ m/2 − 1 + p(m/2 + 1), so p ≥ 1/(m/2 + 1). For odd m the same steps give p ≥ 1/(m + 1).
- Show p ≥ 1/(m/2 + 1) when m is even.
- What does the same argument give for odd m? Evaluate both for m = 8 and m = 9.
- Turn this into an algorithm that finds a cut of size ≥ m/2. Is it Las Vegas or Monte Carlo, and what is its expected number of samples?
Show solution
- Split E[X] at m/2: m/2 = Σi<m/2 i Pr[X=i] + Σi≥m/2 i Pr[X=i] ≤ (m/2 − 1)(1 − p) + m·p, since the small values are ≤ m/2 − 1 and the large ones ≤ m. Rearranging: m/2 ≤ m/2 − 1 + p(m/2 + 1), so p ≥ 1/(m/2 + 1).
- For odd m the largest integer below m/2 is (m−1)/2, giving m/2 ≤ (m−1)/2·(1 − p) + mp ⇒ p ≥ (1/2)/((m+1)/2) = 1/(m + 1). m = 8: p ≥ 1/5. m = 9: p ≥ 1/10. Both are inverse-polynomial, which is all that boosting needs.
- Repeat: sample a random cut, count crossing edges, stop when ≥ m/2. The output is always correct, so it's Las Vegas. The number of samples is geometric with mean 1/p ≤ m/2 + 1 (m = 8: ≤ 5; m = 9: ≤ 10). Alternatively, run a fixed number N of samples and keep the best (Monte Carlo, failure ≤ (1 − p)N).
5.3 Derandomization by conditional expectations ⚑ Flagged in lecture · I24 I25
Why. Can we get the m/2 guarantee with no randomness at all? Decide one vertex at a time, and never let the “expected final cut, if the rest were random” go down.
Order the vertices v₁, …, vₙ (any order). Let xᵢ ∈ {A, B} be vᵢ's side and Φk = E[C(A,B) | x₁, …, xk], with the remaining vertices still fair coins.
Start: Φ₀ (nothing placed yet) is the plain random-cut expectation m/2. Φ₁ = Φ₀ too, because placing the first vertex changes nothing (by symmetry).
Lemma: we can place vk+1 deterministically so that Φk+1 ≥ Φk. Proof: vk+1 would go to A or B with probability ½ each, so Φk = ½·E[C | …, xk+1 = A] + ½·E[C | …, xk+1 = B] ≤ max of the two. Choose the side achieving the max.
Computing it: E[C | first j placed] = (# crossing edges with both endpoints placed) + ½·(# other edges). Only the edges from vk+1 to placed vertices differ between the two choices. So put vk+1 on the side opposite most of its placed neighbors, a greedy rule.
End: Φₙ is the actual cut (no randomness left), and Φₙ ≥ ⋯ ≥ Φ₀ = m/2. ∎ Time O(n + m) with neighbor counters.
- Different vertex orders can give different cuts, all with ≥ m/2 edges: “we hide the random thing in this initial ordering” ⚑ Flagged in lecture · I25.
- The guarantee is ≥ m/2, not optimal.
- Compare conditional expectations, not just “edges so far”. They agree here only because the unplaced edges contribute ½ either way.
Show solution
| vertex | placed nbrs in A / B | E[cut | → A] | E[cut | → B] | choose |
|---|---|---|---|---|
| v1 | 0 / 0 | 9/2 | 9/2 | A |
| v2 | 1 / 0 | 4 | 5 | B |
| v3 | 1 / 1 | 5 | 5 | A |
| v4 | 0 / 1 | 11/2 | 9/2 | A |
| v5 | 2 / 0 | 9/2 | 13/2 | B |
| v6 | 2 / 1 | 6 | 7 | B |
Final cut size 7 ≥ m/2 = 9/2 (here it is even optimal: brute force gives max cut 7). Shortcut: E[cut | ·] = (crossing edges among placed vertices) + ½·(all other edges), so you only compare the new vertex's placed neighbors: put it opposite the majority.
Show solution
Charge each edge to its later endpoint in the processing order, so every edge is charged exactly once. When vertex v is placed, let dv be the number of its already-placed neighbors. Putting v on the side opposite the majority of them makes at least ⌈dv/2⌉ ≥ dv/2 of these edges cross, and later placements never change whether these edges cross. Summing over v: crossing edges ≥ Σ dv/2 = m/2, because Σv dv = m. ∎
Show solution
Start: E = Σ (1 − 2−kⱼ) = 29/8.
| variable | E[· | T] | E[· | F] | choose |
|---|---|---|---|
| x1 | 4 | 13/4 | T |
| x2 | 7/2 | 9/2 | F |
| x3 | 5 | 4 | T |
Final assignment satisfies 5 of 5 clauses (≥ 29/8; brute-force optimum 5). Each conditional expectation is computed clause by clause: a satisfied clause counts 1, a falsified one 0, and a clause with f free literals and no true literal counts 1 − 2−f.
- The probabilistic method proof that a cut of size ≥ m/2 exists also tells us how to find it efficiently.
- The derandomized max-cut algorithm returns the same cut no matter in which order the vertices are processed.
- Max-Cut (find a largest cut) can be solved in polynomial time, just like min-cut.
- In the method of conditional expectations, E[cut | x₁] = m/2 for either placement of the first vertex.
- If Pr[X ≥ m/2] ≥ 1/(m/2+1), then about m/2 + 1 samples are needed in expectation to see a cut of size ≥ m/2.
- The derandomized greedy algorithm for max-cut is a ½-approximation.
For each: True or False, with a 1–2 line justification (Unit 1 exam format).
Show solution
- False. Existence only. Finding needs an extra step: the probability bound plus boosting (Las Vegas), or derandomization.
- False. Deterministic for a fixed order, but different orders can give different cuts, all with ≥ m/2 edges (Nov 3 recap).
- False. Max-Cut is NP-hard (MU §6.2.1; the professor: “finding the largest cut can take us a long time”). Min-cut is in P.
- True. By symmetry: swapping A and B doesn't change the cut size.
- True. The number of samples is geometric with mean 1/p ≤ m/2 + 1 (MU §6.2.1).
- True. It finds ≥ m/2 ≥ OPT/2 edges, deterministically.
5.4 Textbook-only (MU 6.1, 6.4): union bound and sample-and-modify
Assigned reading but not covered in lecture. Lower priority: know the idea in case a short question uses it.
Union bound (MU §6.1). Pr[A₁ ∪ ⋯ ∪ At] ≤ Σ Pr[Aᵢ]. If the bad events' probabilities sum to < 1, the chance that no bad event happens is > 0, so a good object exists. MU's example: color each edge of Kn red or blue at random. A fixed k-clique is monochromatic with probability 21−C(k,2). If C(n,k)·21−C(k,2) < 1, some coloring has no monochromatic Kk. For n = 1000, k = 20 the sum is 4.327×10-16 < 1.
Sample and modify (MU §6.4.1). Sample a random structure that is “almost” good, then repair it. Keep each vertex with probability 1/d (d = 2m/n), then delete one endpoint of each surviving edge. E[result] ≥ n/d − n/(2d) = n²/(4m), so every graph has an independent set of size ≥ n²/(4m). Example: n = 100, m = 300 gives n²/(4m) = 8.33, so some independent set has ≥ 9 vertices.
Large girth (MU §6.4.2). Sample G ~ G(n, p) with p = n1/k − 1. Then E[#edges] = C(n,2)p and E[#cycles of length ≤ k − 1] ≤ k·n(k−1)/k. Delete one edge from each short cycle. For large n the expected number of remaining edges is ≥ ¼·n1+1/k, so for every k ≥ 3 there are graphs with that many edges and girth (shortest cycle) ≥ k: dense, but without short cycles.
Show solution
A fixed k-clique is monochromatic with probability 2·2−C(k,2) (all edges red or all blue). There are C(n,k) cliques, so by the union bound Pr[some monochromatic Kk] ≤ C(n,k)·2−C(k,2)+1. If this is < 1, the complement event has positive probability, so a good coloring exists. For n = 1000, k = 20: C(1000,20)·2−189 = 4.327×10-16 < 1. ✓
Show solution
d = 2m/n = 6. E[surviving vertices] = n/d and E[surviving edges] = (nd/2)(1/d)² = n/(2d). Deleting one endpoint per edge leaves ≥ X − Y vertices, so E[IS size] ≥ n/d − n/(2d) = n/(2d) = n²/(4m). Here n²/(4m) = 25/3 ≈ 8.33. Since a set size is an integer, some independent set has ≥ 9 vertices.
Why does E[cut] = m/2 imply a cut of size ≥ m/2 exists?
How do you get p ≥ 1/(m/2+1)?
Derandomization rule in one sentence?
Does the vertex order matter?
6 · Randomized rounding: MAX-SAT
Nov 5 (OMS video LP4, sections 1–24) · Lec 18 typed notes (“Randomized Approximation for MAX-SAT”) · MU 6.2.2. The guarantee is always in expectation ⚑ Flagged in lecture · I31.
- get ½ (and 7/8 for exact-3) from fair coins by linearity
- write the MAX-SAT ILP, relax it, and explain LP* ≥ OPT
- prove the rounding lemma Pr[Cⱼ sat] ≥ (1 − 1/e)ẑⱼ step by step
- prove the ¾ best-of-two bound by averaging
- read off the strongest bounds on OPT from a guarantee, an LP value and a solution
6.1 MAX-SAT and the fair-coin ½-approximation
Why. SAT is NP-complete, and its optimization version MAX-SAT (satisfy as many clauses as possible) is NP-hard. So we aim for an assignment that is provably close to the optimum M* without knowing M*. An α-approximation outputs L ≥ α·M* satisfied clauses on every formula.
Algorithm: set each xᵢ = T with probability ½, independently, without even looking at the formula.
Analysis (clause by clause): W = Σⱼ Wⱼ with Wⱼ = 1 if Cⱼ is satisfied. A clause with k distinct literals is false for exactly one setting of its variables, which has probability 2−k. So E[Wⱼ] = 1 − 2−k ≥ ½, and by linearity E[W] ≥ m/2 ≥ M*/2. (Weighted version: Σ wⱼE[Wⱼ] ≥ ½Σwⱼ ≥ ½OPT.)
Derandomize exactly as for max-cut: fix x₁, x₂, … in turn, each time choosing the value with the larger conditional expectation (computable clause by clause). This gives ≥ m/2 deterministically.
6.2 MAX-E3SAT: 7/8, and it's optimal ⚑ Flagged in lecture · I28 I29
Mechanism. If every clause has exactly three distinct literals, each clause fails with probability 1/8, so E[W] = 7m/8 ≥ 7/8·M*. Håstad: doing better than 7/8 + ε for any fixed ε > 0 is NP-hard. So this naive algorithm is the best possible unless P = NP. In general, MAX-Ek-SAT gets 1 − 2−k.
Show solution
The proof uses Pr[clause fails] = (½)³ for every clause. A unit clause fails with probability ½ and a 2-clause with ¼, so the expected fraction can drop to ½. E.g. the formula (x) ∧ (¬x): fair coins satisfy exactly 1 of 2 clauses. Only the general bound E ≥ m/2 survives. (Also needed: the three literals are distinct variables, so the events are independent.)
6.3 ILP formulation and LP relaxation
Why. Fair coins ignore the formula. An LP can “tell us that some variables should be more likely true than false.” Plan: write MAX-SAT exactly as an ILP (NP-hard to solve), drop integrality to get an LP (poly time), then round the fractional answer back to an assignment.
ILP. Variables yᵢ ∈ {0,1} (xᵢ true ⇔ yᵢ = 1) and zⱼ ∈ {0,1} (“clause j counted”). With Cⱼ⁺ / Cⱼ⁻ the indices of positive / negated variables in Cⱼ: maximize Σⱼ zⱼ subject to zⱼ ≤ Σi∈Cⱼ⁺ yᵢ + Σi∈Cⱼ⁻ (1 − yᵢ). If every literal of Cⱼ is false, the right side is 0 and forces zⱼ = 0. Otherwise zⱼ may be 1, and the maximization makes it 1. So ILP optimum = M*. (This is also the reduction Max-SAT → ILP that proves ILP is NP-hard.)
LP relaxation. Replace {0,1} by [0,1]. Every integer solution is still feasible and the LP maximizes over more points, so LP* = Σẑⱼ ≥ M*.
Show solution
Constraint: z ≤ y₁ + (1 − y₂) + y₃.
Satisfying, e.g. x = (T, T, F): RHS = 1 + 0 + 0 = 1, so z can be 1 and the maximization sets it to 1. The clause is counted.
Unsatisfying, the unique one x = (F, T, F): RHS = 0 + 0 + 0 = 0, so z = 0. The clause is not counted.
- Write the ILP for MAX-SAT and its LP relaxation.
- OPT = ? (brute force) LP* = ? (the LP solver gives an optimal solution ŷ1 = 0.5, ŷ2 = 0.5, ẑ1 = 1, ẑ2 = 0.5, ẑ3 = 1)
- Why must LP* ≥ OPT?
- Compute the expected number of satisfied clauses under fair coins and under LP rounding with this ŷ.
Show solution
- max z₁ + z₂ + z₃ s.t. z₁ ≤ y₁ + (1 − y₂), z₂ ≤ y₂, z₃ ≤ (1 − y₁) + (1 − y₂), with y, z ∈ {0,1} (ILP), or 0 ≤ y, z ≤ 1 (LP).
- OPT = 2: no assignment satisfies all three. LP* = 2.5.
- Every integer solution is LP-feasible and the LP maximizes over a larger set (relaxation).
- Fair coins: ¾ + ½ + ¾ = 2. LP rounding with ŷ = (½, ½): also 2.0000. Both are ≥ (1 − 1/e)·LP* and ≥ ½·OPT, as guaranteed.
6.4 Randomized rounding and the 1 − 1/e lemma ⚑ Flagged in lecture · I27
Mechanism. Solve the LP and get (ŷ, ẑ). Set xᵢ = T independently with probability ŷᵢ. Only the y's are rounded; the z's are implied.
Lemma. Pr[Cⱼ satisfied] ≥ (1 − 1/e)·ẑⱼ.
Let Cⱼ have k literals with individual truth probabilities p₁, …, pₖ (pᵣ = ŷᵢ for xᵢ, 1 − ŷᵢ for ¬xᵢ). The LP constraint reads Σpᵣ ≥ ẑⱼ. The variables are distinct and rounded independently, so Pr[Cⱼ sat] = 1 − ∏r(1 − pᵣ).
AM–GM (arithmetic mean ≥ geometric mean): for non-negative w₁, …, wₖ, (w₁w₂⋯wₖ)1/k ≤ (w₁ + ⋯ + wₖ)/k, equivalently ∏wᵣ ≤ ((1/k)Σwᵣ)k. Apply it to the non-negative numbers wᵣ = 1 − pᵣ: ∏(1 − pᵣ) ≤ ((1/k)Σ(1 − pᵣ))k = (1 − (Σpᵣ)/k)k ≤ (1 − ẑⱼ/k)k. So Pr[Cⱼ sat] ≥ 1 − (1 − ẑⱼ/k)k.
Concavity: f(z) = 1 − (1 − z/k)k is concave on [0,1] with f(0) = 0, so f(z) ≥ f(1)·z = βₖ·z with βₖ = 1 − (1 − 1/k)k.
Constant: 1 − x ≤ e−x gives (1 − 1/k)k ≤ 1/e, so βₖ ≥ 1 − 1/e ≈ 0.6321. (The typed notes take a shortcut: (1 − z/k)k ≤ e−z, then 1 − e−z ≥ (1 − 1/e)z by concavity.)
Theorem. E[W] = Σⱼ Pr[Cⱼ sat] ≥ (1 − 1/e)Σⱼẑⱼ = (1 − 1/e)LP* ≥ (1 − 1/e)M*. ∎
- Rounding is per variable, independent, with probability ŷᵢ. Not “ŷᵢ ≥ ½ ⇒ true” (that can satisfy nothing, see 6.10).
- Negated literals use 1 − ŷᵢ.
- The bound compares to ẑⱼ, not to 1. A clause with small LP value gets a small guarantee.
- In expectation only.
- Exact Pr[clause satisfied] after randomized rounding?
- Compare with the AM–GM bound 1 − (1 − ẑ/k)k, with β₃ẑ, and with (1 − 1/e)ẑ.
- Now the clause (¬x₁ ∨ ¬x₂) with ŷ₁ = 0.9, ŷ₂ = 0.6. What is the largest feasible ẑ, and Pr[satisfied]? Check it is ≥ β₂ẑ.
Show solution
- Fails only if all three are false: 0.5·0.7·0.8 = 0.2800, so Pr = 0.7200.
- 1 − (1 − 1/3)³ = 0.7037 = β₃·1 (here Σŷ = ẑ = 1, so the AM–GM bound equals β₃ẑ). (1 − 1/e)·1 = 0.6321. Order: 0.7200 ≥ 0.7037 ≥ 0.6321.
- ẑ ≤ (1 − 0.9) + (1 − 0.6) = 0.5000. Literal probabilities: Pr[¬x₁ true] = 0.1, Pr[¬x₂ true] = 0.4. Pr[sat] = 1 − 0.9·0.6 = 0.4600 ≥ β₂ẑ = ¾·0.5 = 0.3750. ✓ (For negated literals, use 1 − ŷᵢ as the literal's probability.)
Show solution
g(z) = 1 − e−z is concave (e−z is convex, and the negative of a convex function is concave). Any z ∈ [0,1] is the convex combination z = (1 − z)·0 + z·1, so concavity gives g(z) ≥ (1 − z)g(0) + z·g(1) = (1 − z)·0 + z(1 − 1/e) = (1 − 1/e)z. ∎ (The curve lies above its chord from (0, 0) to (1, 1 − 1/e).)
Show solution
Let Cⱼ have k literals with satisfaction probabilities p₁, …, pₖ (pᵣ = ŷᵢ for xᵢ, 1 − ŷᵢ for ¬xᵢ). The LP constraint says Σpᵣ ≥ ẑⱼ. The variables are distinct and independent, so Pr[sat] = 1 − ∏(1 − pᵣ). AM–GM on the k numbers 1 − pᵣ: ∏(1 − pᵣ) ≤ ((1/k)Σ(1 − pᵣ))k = (1 − Σpᵣ/k)k ≤ (1 − ẑⱼ/k)k. So Pr[sat] ≥ 1 − (1 − ẑⱼ/k)k =: f(ẑⱼ). f is concave on [0,1] with f(0) = 0, so f(z) ≥ f(1)·z = βₖz. Finally (1 − 1/k)k ≤ e−1 (from 1 − x ≤ e−x), so βₖ ≥ 1 − 1/e.
Linearity: E[#sat] = Σⱼ Pr[Cⱼ sat] ≥ (1 − 1/e)Σⱼẑⱼ = (1 − 1/e)LP* ≥ (1 − 1/e)OPT. ∎
- Brute-force OPT is 5. Confirm LP* ≥ OPT makes sense.
- Expected satisfied clauses: fair coins = 37/8; LP rounding = 4.8148. Which guarantees do these numbers respect?
- What does the best-of-two algorithm guarantee here?
Show solution
- The LP is a relaxation, so its value can exceed the best integer value (5.66667 > 5).
- Fair: 37/8 ≥ m/2 = 3.5. LP rounding: 4.8148 ≥ (1 − 1/e)·LP* = 3.5820 ≥ (1 − 1/e)·OPT.
- E[max] ≥ average = 4.7199 ≥ ¾·LP* = 4.2500.
Show solution
Take the clause (x₁ ∨ ⋯ ∨ xₖ), k ≥ 3, with ŷᵢ = 1/k for all i. Then Σŷᵢ = 1, so ẑ = 1 is feasible. Every ŷᵢ < ½, so threshold rounding sets all of them false and the clause fails. Randomized rounding fails only with probability (1 − 1/k)k ≤ 1/e. The coins exploit the fractional mass spread across the literals; the threshold throws it away.
6.5 Best of two: a ¾-approximation ⚑ Flagged in lecture · I30
Why. Fair coins are strong on long clauses (αₖ = 1 − 2−k) and weak on unit clauses. LP rounding is the reverse (βₖ = 1 − (1 − 1/k)k: 1 at k = 1, falling toward 1 − 1/e). They complement each other.
| clause size k | fair coins αₖ | LP rounding βₖ | better | αₖ + βₖ |
|---|---|---|---|---|
| 1 | 1/2 | 1 | 1 | 1.5000 |
| 2 | 3/4 | 3/4 | 3/4 | 1.5000 |
| 3 | 7/8 | 19/27 ≈ 0.7037 | 7/8 | 1.5787 |
| 4 | 15/16 | ≈ 0.6836 | 15/16 | 1.6211 |
Algorithm: run both and output the better assignment: max(M₁, M₂) satisfied clauses.
Proof (correct version): max(M₁, M₂) ≥ ½(M₁ + M₂), so E[max] ≥ ½(E[M₁] + E[M₂]) ≥ Σⱼ ½(αₖ + βₖ)·ẑⱼ ≥ ¾·LP* ≥ ¾·M*. This uses αₖ ≥ αₖẑⱼ (since ẑⱼ ≤ 1) and αₖ + βₖ ≥ 3/2 for every k (verified by script for k up to 5000; the minimum is 1.5000, at k = 1, 2; the limit is 1.6321). ∎
Show solution
| k | αₖ | βₖ | max | αₖ + βₖ |
|---|---|---|---|---|
| 1 | 1/2 = 0.5000 | 1 = 1.0000 | 1.0000 | 1.5000 |
| 2 | 3/4 = 0.7500 | 3/4 = 0.7500 | 0.7500 | 1.5000 |
| 3 | 7/8 = 0.8750 | 19/27 = 0.7037 | 0.8750 | 1.5787 |
| 4 | 15/16 = 0.9375 | 175/256 = 0.6836 | 0.9375 | 1.6211 |
The better factor is always ≥ ¾ and the sum is always ≥ 3/2 (minimum 1.5000, at k = 1 and k = 2). Fair coins win for k ≥ 3, the LP wins for k = 1, and they tie at k = 2.
Show solution
max(M₁, M₂) ≥ (M₁ + M₂)/2 pointwise, so E[max] ≥ ½(E[M₁] + E[M₂]). For a clause Cⱼ of size k: Prfair[Cⱼ sat] = αₖ ≥ αₖẑⱼ (since ẑⱼ ≤ 1) and PrLP[Cⱼ sat] ≥ βₖẑⱼ. Summing over clauses with linearity: ½(E[M₁] + E[M₂]) ≥ Σⱼ ½(αₖ + βₖ)ẑⱼ ≥ ¾ Σⱼ ẑⱼ = ¾·LP* ≥ ¾·OPT. ∎
Why not the video's version: “for each clause take whichever algorithm is better” describes a different, imaginary per-clause choice. The algorithm picks one whole assignment, so you must average.
- Each run of LP-guided rounding satisfies at least (1 − 1/e)·OPT clauses.
- For a maximization ILP, the LP relaxation's optimal value is at most the ILP's optimal value.
- In MAX-SAT randomized rounding we must also round the zⱼ variables.
- A polynomial-time 0.88-approximation for MAX-E3SAT would imply P = NP.
- Fair coins give a 7/8-approximation for MAX-3SAT when clauses have at most 3 literals.
- Integer linear programming is NP-hard, while linear programming is in P.
For each: True or False, with a 1–2 line justification (Unit 1 exam format).
Show solution
- False. The guarantee is in expectation; a single run can be lower (Lec 18 typed notes).
- False. It's at least: the relaxation has more feasible points (LP* ≥ OPT).
- False. Only the yᵢ are rounded. The resulting assignment determines which clauses are satisfied.
- True. Håstad: doing better than 7/8 is NP-hard, and 0.88 > 0.875.
- False. 7/8 needs exactly 3 distinct literals per clause; unit clauses are satisfied with probability only ½.
- True. LP4: “Linear programming is solvable in polynomial time… integer linear programming is NP-hard”, shown via Max-SAT → ILP.
6.6 Reading off bounds on OPT (the “strongest bounds” question) ⚑ Past exam / HW · I79
Why. Exam 2 had an 8-point part (Q1(f)): “an algorithm returned X, you also know Y; what are the strongest lower and upper bounds on OPT?” Exam 1 asked the same kind of question (“80 ≤ OPT ≤ 100”). It tests whether you know which way each guarantee points. It always includes one piece of information that turns out to be useless.
Definitions. Maximization: an α-approximation (α ≤ 1) always outputs value ALG ≥ α·OPT. Minimization: an α-approximation (α ≥ 1) always outputs cost ALG ≤ α·OPT.
Rules. (1) A feasible solution of value v bounds OPT on one side: OPT ≥ v for a max, OPT ≤ v for a min. (2) A guarantee applied to that v bounds the other side: max ⇒ OPT ≤ v/α; min ⇒ OPT ≥ v/α. (3) LP relaxation: max ⇒ OPT ≤ LP*; min ⇒ OPT ≥ LP*. With an integer objective you may round: OPT ≤ ⌊LP*⌋ or OPT ≥ ⌈LP*⌉. (4) Expectation μ of a random solution: some solution reaches μ (probabilistic method, §5.1), so OPT ≥ μ for a max (OPT ≤ μ for a min). (5) Trivial bounds: Max-SAT and Max-Cut have OPT ≤ m. (6) Take the largest lower bound and the smallest upper bound, and say why the others are weaker.
- A guarantee in expectation says nothing about one run: if one run of an expected ¾-approximation satisfies 30 clauses, you get OPT ≥ 30, but not OPT ≤ 40.
- Don't mix up the directions for max and min. Always ask: “is this a solution (one side) or a guarantee/relaxation (other side)?”
- The “extra fact” is often weaker than what you already have. Say so in one sentence.
- A Set Cover instance: the LP relaxation has optimal value 7.4, and randomized rounding + repetition returned a cover with 19 sets.
- MAX-SAT with m = 30 clauses, every clause with exactly 3 distinct literals. One run of the LP-rounding algorithm (expected (1 − 1/e)-approximation) satisfied 24 clauses.
- Vertex Cover: a 2-approximation returned 14 vertices, and someone shows you an independent set of size 5 in this 20-vertex graph.
Show solution
- 8 ≤ OPT ≤ 19. Min problem: the LP relaxation gives OPT ≥ 7.4, and OPT is an integer, so OPT ≥ 8. The cover found is feasible, so OPT ≤ 19.
- 27 ≤ OPT ≤ 30. Exactly-3 clauses: E[fair coins] = 7·30/8 = 26.25, so some assignment satisfies ≥ 27 (integer). The run's 24 is a weaker lower bound. Upper: OPT ≤ m = 30. The expected guarantee says nothing about this single run, so “24 ≥ (1 − 1/e)OPT” is not valid.
- 7 ≤ OPT ≤ 14. Upper: the returned cover. Lower: 14 ≤ 2·OPT. The independent set gives only OPT ≤ 20 − 5 = 15 (its complement is a cover, §11.3), which is weaker than 14.
The four steps of the rounding lemma?
When does 7/8 hold?
Why average in the ¾ proof?
Min problem: a 2-approx returns 20. Bounds?
Which variables get rounded?
7 · Formula and bounds table
Everything you might need to write from memory, or put on a note sheet. Numbers come from calc.py.
| Piece | Formula | In plain words |
|---|---|---|
| Bernoulli(p) | Pr[X=1] = p, Pr[X=0] = 1−p, E = p | One trial: success or not |
| Binomial(n,p) | Pr[X=k] = C(n,k)pk(1−p)n−k, E = np | Number of successes in n independent trials |
| Geometric(p) | Pr[X=k] = (1−p)k−1p, k ≥ 1; E = 1/p; Pr[X ≤ N] = 1 − (1−p)N | Trials until the first success. “Repeat until it works.” |
| Expectation | E[X] = Σₓ x·Pr[X=x] | Probability-weighted average |
| Indicator | E[I] = Pr[I = 1] | The expectation of a 0/1 variable is the chance it's 1 |
| Linearity | E[ΣXᵢ] = ΣE[Xᵢ] (no independence needed) | Break a count into indicators, sum their probabilities |
| Markov | X ≥ 0, a > 0: Pr[X ≥ a] ≤ E[X]/a | Being a times the mean is at most 1/a likely. Loose. |
| Chain rule | Pr[E₁∩⋯∩Et] = ∏ Pr[Eᵢ | E₁…Ei−1] | Multiply step-by-step chances, each given the good past |
| Disjoint events | Pr[∪Aᵢ] = ΣPr[Aᵢ] ≤ 1 | One run returns one cut ⇒ #min cuts ≤ n(n−1)/2 (§15.1) |
| Tail sum | E[T] = Σt≥0 Pr[T > t] (T ∈ {0,1,2,…}) | Expected number of rounds from “Pr[still not done after t]” |
| Union bound (MU 6.1) | Pr[∪Aᵢ] ≤ ΣPr[Aᵢ] | The chance something bad happens is at most the sum of the individual chances |
| Exponential bound | 1 − x ≤ e−x; (1 − 1/n)n ≤ 1/e; (1 − p)N ≤ e−pN | Turns repeated failure into an exponential. (1−1/n)n: n=2 → 0.2500, n=10 → 0.3487, n=100 → 0.3660; 1/e = 0.3679 |
| Probabilistic method | E[X] = μ ⇒ Pr[X ≥ μ] > 0 and Pr[X ≤ μ] > 0 | Some outcome is at least the average, so a good object exists |
| Karger, one run | Pr[return fixed min cut Δ] ≥ ∏(1 − 2/(n−k+1)) = 2/(n(n−1)) | Degree bound |Δ| ≤ 2|E|/|V|, then telescope. n = 10: 1/45; n = 1000: 2.002×10-6 |
| Boosting | Pr[success in N runs] ≥ 1 − (1 − p)N ≥ 1 − e−pN; N = ⌈ln(1/δ)/p⌉ ⇒ failure ≤ δ | p⁻¹ polynomial ⇒ polynomially many runs. Karger: N = n(n−1) ln n ⇒ failure ≤ 1/n² |
| Random cut | Pr[edge crosses] = ½; E[cut] = m/2 | Every graph has a cut ≥ m/2. Expected ½-approximation for Max-Cut |
| Large-cut probability | Pr[X ≥ m/2] ≥ 1/(m/2 + 1) (m even), ≥ 1/(m+1) (m odd) | Split E[X] at m/2 and bound each side by its largest value |
| Conditional expectations | Φk = ½Φk+1(A) + ½Φk+1(B) ≤ max | Pick the side that keeps the expectation from dropping: greedy |
| Fair-coin MAX-SAT | Pr[Cⱼ sat] = 1 − 2−kⱼ ≥ ½; E ≥ m/2 | ½-approximation; 7/8 for exactly-3 clauses (optimal unless P = NP) |
| MAX-SAT ILP | max Σzⱼ, zⱼ ≤ ΣCⱼ⁺yᵢ + ΣCⱼ⁻(1−yᵢ), y,z ∈ {0,1} | zⱼ is forced to 0 exactly when every literal is false |
| Relaxation | LP* ≥ OPT (max problem); LP* ≤ OPT (min problem) | More feasible points can only help |
| AM–GM | ∏wᵢ ≤ ((1/k)Σwᵢ)k, wᵢ ≥ 0 | Turns the product of failure probabilities into the sum the LP controls |
| Rounding lemma | Pr[Cⱼ sat] ≥ 1 − (1 − ẑⱼ/k)k ≥ βₖẑⱼ ≥ (1 − 1/e)ẑⱼ | 1 − 1/e ≈ 0.6321; βₖ = 1 − (1 − 1/k)k: k=1 → 1, k=2 → ¾, k=3 → 19/27 |
| Concavity trick | f concave, f(0) = 0 ⇒ f(z) ≥ f(1)·z on [0,1] | A concave curve lies above its chord |
| Best of two | E[max(M₁,M₂)] ≥ ½(E[M₁]+E[M₂]) ≥ ¾LP*, since αₖ + βₖ ≥ 3/2 | ¾-approximation for MAX-SAT |
| Min cuts / α-small cuts | #min cuts ≤ C(n,2); #cuts ≤ αλ ≤ C(n,2α)·22α−1 = O(n2α) | Stop contracting at 2α supervertices, then a random split |
| Covering by rounding + repetition | Pr[constraint missed after t rounds] ≤ e−t; E[T] ≤ ⌈ln M⌉ + 1.582; E[cost] = LP*·E[T] | Union of independent roundings: O(log M)-approximation for hitting set / set cover |
| Repetition protocol | Pr[cheater passes N rounds] ≤ (1 − 1/m)N ≤ e−N/m; N ≥ m ln(1/ε) | One bad edge out of m per round; fresh coins each round |
| Bounds on OPT | max: v ≤ OPT ≤ min(v/α, LP*); min: max(v/α, LP*) ≤ OPT ≤ v | A solution bounds one side; a guarantee or relaxation the other (§6.6) |
| Reduction A → B | f, g poly time; I solvable ⇔ f(I) solvable; g(S) solves I | B is at least as hard as A |
| What it preserves | A NP-hard ⇒ B NP-hard; B ∈ P ⇒ A ∈ P; both ⇒ P = NP | Hardness flows forward, easiness backward |
| Classes | P ⊆ NP; NP-complete = NP ∩ NP-hard | NP = verifiable in poly time (search problems); P = solvable. NP = nondeterministic poly time |
| NP-complete proof | B ∈ NP + (known NP-complete K) → B | Every A ∈ NP: A → K → B by composition. FROM the known TO the new |
| Clause splitting | k literals → k − 2 clauses, k − 3 new variables | (x₁∨x₂∨y₁)(¬y₁∨x₃∨y₂)…(¬yk−3∨xk−1∨xₖ) |
| 2-SAT edge rule | (a ∨ b) ⇒ ¬a → b and ¬b → a | Unsatisfiable ⇔ some x and ¬x share an SCC. Assign: sink SCC true, its complement false, repeat (GR2) |
| 3-SAT → IS | vertex per literal occurrence; clause cliques + complement edges; k = m | One true literal per clause, no contradictions |
| IS / Clique / VC | S indep in G ⇔ S clique in Ĝ ⇔ V∖S vertex cover of G | One set, three views: max IS size + min VC size = n |
8 · Map of complexity classes and reductions
The whole hardness half of the unit on one page. Details in §9–§11.
9 · P, NP, NP-hard and reductions
Nov 10 lecture + board (Lec 19) · KT 8.1, 8.3, 8.4 for textbook-only remarks. The course uses search problems, not decision problems. Answer with the course's definitions.
- define search problem, P, NP, NP-hard and NP-complete in the course's terms
- state what a reduction A → B needs (f, g, ⇔, polynomial time)
- draw the right conclusion from A → B in each case (hardness forward, easiness backward)
9.1 Why polynomial time means “efficient”
Intuition (lecture). Every problem here is finite, so you can always “try everything”. The real question is whether we can do it efficiently. Two principles: (1) linear time must count as efficient, since you have to read the input; (2) composing and nesting efficient steps must stay efficient (loop after loop, loop inside loop). Polynomials are exactly the family closed under these operations. Exponentials are not efficient: 2200 for a 200-bit input is “an ocean” you can't search.
Mechanism. If f takes O(na) time, its output has size O(na). Feeding it to an O(Nb) algorithm costs O(nab). Still polynomial. This is why reductions must be polynomial time.
Show solution
f outputs at most O(n²) symbols (it can't write more than its running time), so B's algorithm runs on N = O(n²): O((n²)³) = O(n6), plus O(n²) for f. Polynomial. Polynomials are closed under composition and sums, which is the professor's “sequence and nest efficient steps and stay efficient” idea. That's what makes “solve A via B” efficient whenever B is.
9.2 Search problems, NP, P, NP-hard, NP-complete ⚑ Flagged in lecture · I37 I38 I39
Why. “Hardness has to be defined, not declared.” Saying “nobody knows a fast algorithm” could just mean we're ignorant. We need a definition that lets us prove statements like “if you solve this, you solve everything”.
Search problem: given an input I and a candidate solution S, a verifier checks in polynomial time whether S is a solution for I. (Shortest path: check the path. Independent set: count the vertices and check for no internal edges.)
NP = the class of all search problems. P = the search problems that can be solved in polynomial time. So P ⊆ NP. Whether P = NP is open.
NP-hard: A is NP-hard if every problem in NP reduces to A with f and g polynomial time. NP-hard problems “don't have to be search problems”.
NP-complete = NP ∩ NP-hard: verifiable in poly time, and everything in NP reduces to it.
Cook–Levin (stated, not proved): SAT is NP-hard. (KT proves the Circuit-SAT version.)
How to prove “X is in NP” (one or two sentences) video ⚑ OMS video (extra) · I71 I73
The NP1 video's recipe: (i) the problem has the search form (output a solution if one exists, otherwise NO); (ii) give a verifier: on input I and a proposed solution S, check S in time polynomial in |I|. You never have to find S. The examples below are the ones the video does:
| Problem | Verifier (what you write) | Time |
|---|---|---|
| SAT | For each of the m clauses, check that some literal is true under the assignment. | O(nm) |
| 3-SAT | Same, but each clause has ≤ 3 literals. | O(m) |
| k-coloring | For every edge {v, w}, check that v and w got different colors (and every color is in 1..k). | O(n + m) |
| Independent set (size ≥ g) | Check |S| ≥ g and that no edge has both endpoints in S. | O(n + m) |
| MST | Check T is a spanning tree (BFS/DFS); run Kruskal or Prim and compare weight(T) with the weight of their MST. | O(m log n) |
| Knapsack-search | Check Σi∈S wᵢ ≤ B and Σi∈S vᵢ ≥ g. | O(n log W) bit operations |
MST is in NP and in P. An optimization problem can be in NP when optimality is checkable in polynomial time; for MST we just recompute an optimum and compare weights. It's in P because Kruskal/Prim also find it. Knapsack differs exactly here: the only optimum-finder we know is pseudo-polynomial.
Knapsack-search (the fix). Add a goal g to the input: find a subset S with total weight ≤ B and total value ≥ g, or output NO. This is a search problem (verifier in the table), so it's in NP. And it is just as useful as the optimization version: binary search on g over [0, V], where V = Σvᵢ, finds the maximum achievable value with ⌈log₂(V + 1)⌉ calls. log V is part of the input size, so that's polynomial. (Why “≥ g” and not “≤ g”? “≤ g” is trivial: the empty set always works.)
What “NP” stands for: nondeterministic polynomial time, not “not polynomial” video ⚑ OMS video (extra) · I74. Why NP-complete = “hardest in NP”: if any one NP-complete problem is in P, then P = NP. Equivalently, if P ≠ NP, no NP-complete problem is in P.
- NP does not mean “not polynomial”. P ⊆ NP.
- Don't write “NP-hard problems can't be solved in polynomial time”. Write “no polynomial-time algorithm is known; one would imply P = NP”.
- NP-hard ⇏ in NP (Max-SAT, ILP as optimization problems).
- Student summary confirmed in class: “P we can solve and check in polynomial time; NP we can (only) check.” Yes.
Show solution
- Search problem: given an input I and a candidate solution S, a verifier checks in polynomial time whether S is a solution for I.
- NP: the class of all search problems. P: the search problems that can be solved in polynomial time (P ⊆ NP).
- NP-hard: every problem in NP reduces to it (f and g poly time). NP-complete: NP ∩ NP-hard.
No. NP-hard problems “don't have to be search problems”. Max-SAT or ILP as optimization problems are NP-hard but not in NP under this definition, because you can't verify optimality in poly time.
- Shortest s–t path.
- Independent set: given G and k, find an independent set of size ≥ k.
- Knapsack as in class: find the most valuable subset within capacity B.
- Max-SAT: find an assignment maximizing the number of satisfied clauses.
- 2-SAT.
Show solution
- In NP (checking a path's length against a shortest-path computation is poly) and in P.
- In NP: count the vertices and check no edge inside. Poly-time solvability is unknown; it's NP-complete.
- Not known to be in NP (the lecture: “not a search problem” as seen in class): verifying optimality would need the DP, which is pseudo-polynomial (time depends on B, exponential in its bit length). Also not known to be in P. Knapsack-search (value ≥ g) is in NP (problem 9.10).
- Not in NP as an optimization problem (you can't check that the count is maximum), but NP-hard (SAT → Max-SAT).
- In NP and in P (SCCs of the implication graph).
- (2) Show knapsack-search is in NP.
- (4) Suppose a black box solves knapsack-search in polynomial time. Solve optimization knapsack in polynomial time and bound the number of calls in terms of V = Σvᵢ. Why is that polynomial?
- (1) Why does the definition say value ≥ g and not value ≤ g?
- (3) Run your method on (w, v) = (3, 4), (4, 5), (2, 3), (5, 8), B = 9: how many calls, and what is the optimum?
- (2) Is optimization knapsack in NP? Answer in the course's terms.
Show solution
- Given S, check Σi∈Swᵢ ≤ B and Σi∈Svᵢ ≥ g: two sums of at most n numbers, O(n log W) bit operations, polynomial in the input size. It has the search form (a solution or NO), so it's in NP.
- Binary search on g ∈ [0, V]: if the box finds a subset for goal g, the optimum is ≥ g; if it says NO, the optimum is < g. That takes ⌈log₂(V + 1)⌉ calls. The box's answer at the largest feasible g is an optimal subset. V is written in O(n log V_max) bits, so log V is at most the input size, and the total time is polynomial.
- “≤ g” would be trivial: the empty set always has value 0 ≤ g. We want to push the value up.
- V = 20: binary search makes 5 calls (≤ ⌈log₂ 21⌉ = 5), and the optimum is 13, using items {2, 4} (weights 4 + 5 = 9, values 5 + 8 = 13).
- Not known to be in NP: we know no polynomial-time way to verify that a subset is optimal, since our only optimum-finder is the O(nB) DP, which is pseudo-polynomial. Not known to be in P either. (Proving it's not in NP would prove P ≠ NP.)
Select ALL that apply.
Show solution
Correct: 1, 2, 5, 6
- ✔ Verify T is a spanning tree (BFS/DFS) and compare its weight with Kruskal's/Prim's MST: O(m log n).
- ✔ Kruskal/Prim find it in polynomial time.
- ✘ Not known: verifying optimality needs the pseudo-polynomial DP.
- ✘ Nondeterministic polynomial time. P ⊆ NP.
- ✔ Each clause has at most 2n literals, so O(n) per clause, m clauses (NP1 video).
- ✔ If one NP-complete problem were in P, every NP problem would be (all reduce to it), so P = NP. Contrapositive.
- ✘ Wrong direction: that only shows B is no harder than SAT. Reduce a known NP-complete problem TO B.
9.3 Reductions: f, g, and the if-and-only-if ⚑ Flagged in lecture · I34 I35 I36
Intuition. To solve problem A, translate its input into an input of B, run a black box for B (the professor's “tesseract”), and translate the answer back. If that works, B is at least as hard as A.
A reduction A → B consists of two polynomial-time algorithms: f maps every input I of A to an input f(I) of B, and g maps every solution S of f(I) to a solution g(S) of I.
Correctness: I has a solution ⇔ f(I) has a solution, and if S solves f(I) then g(S) solves I. The ⇔ also covers “no solution”: if B's box says NO, A's answer is NO.
No other restrictions: f need not be injective or onto. f and g depend on the specific pair (A, B).
Notation: the NP1 video calls the recovery map h; the lecture (and these notes) call it g. Same thing video.
Transitivity (KT 8.9): A → B and B → C give A → C, by composing f's and g's (polynomials compose).
Show solution
Two requirements fail. (1) The ⇔ fails: f(I) always has a solution, even when I has none. (2) No useful g: the answer (the edge 1–2) carries no information about I, so no poly-time g can turn it into a solution of I. f and g must be designed together so that a solution of f(I) can be translated back.
9.4 Direction: which way does the arrow go? ⚑ Flagged in lecture · I33 I41
Rule. To prove a new problem B is hard, reduce a known hard A to B (A → B). Then “solving B solves A, and A solves everybody”. The relation is not symmetric.
Why one reduction is enough (NP1 video video): NP-complete needs “every A ∈ NP reduces to B”. If a known NP-complete problem K reduces to B, then every A ∈ NP satisfies A → K → B by composing the reductions. So: B is NP-complete ⇔ (1) B ∈ NP and (2) K → B for some known NP-complete K. The video calls the wrong direction the classic student error: “Often they'll show the reduction in the other direction. That's not really proving anything” ⚑ OMS video (extra) · I70.
Lecture examples: shortest path → SAT (true, since shortest path ∈ NP and SAT is NP-hard), but SAT → shortest path would put SAT in P and give P = NP. Independent set → SAT exists (IS ∈ NP), but it isn't the 3-SAT → IS construction run backwards.
- B reduces to A.
- A reduces to B.
- Either direction works.
- Both directions are needed.
Show solution
(b) A → B. Then a poly-time algorithm for B would solve A, and hence everything in NP. B → A would only say B is no harder than A.
Shortest path → SAT holds (shortest path ∈ NP, Cook–Levin). SAT → shortest path is not known: it would put SAT in P and give P = NP. Reductions are not symmetric.
9.5 What a reduction preserves ⚑ Flagged in lecture · I40 I03 I56
Let A → B. The Nov 12 summary (“two conclusions to make explicit in your notes”, plus a third “dramatic” one):
| Known | Conclude | Why |
|---|---|---|
| A is NP-hard | B is NP-hard | Everything → A → B (transitivity) |
| B ∈ P | A ∈ P | Solve A by f, B's algorithm, g, all polynomial |
| A NP-hard and B ∈ P | P = NP | Everything → A, which is now poly time |
| A ∈ P | nothing about B | Easy problems reduce to hard ones (shortest path → SAT) |
| B NP-hard | nothing about A | Every NP problem reduces to an NP-hard B |
- A is NP-hard.
- B ∈ P.
- A ∈ P.
- B is NP-hard.
- B ∈ NP and A is NP-hard.
Show solution
- B is NP-hard.
- A ∈ P (solve A by f, then B's algorithm, then g).
- Nothing about B. Easy problems reduce to hard ones all the time.
- Nothing about A. Everything in NP reduces to an NP-hard B, easy problems included.
- B is NP-hard (from A) and in NP, so B is NP-complete.
Show solution
B ∈ P ⇒ A ∈ P (reductions carry easiness backward). A is NP-hard, so every NP problem reduces to A and is in P. P = NP. (So we don't expect such a reduction to exist, but that's what it would imply.)
- In a reduction A → B, the map f must be injective (one-to-one).
- NP-hard problems cannot be solved in polynomial time.
- P ⊆ NP.
- Every NP-hard problem belongs to NP.
- The functions f and g in a reduction can be chosen independently of A and B.
- If one NP-complete problem has a polynomial-time algorithm, then P = NP.
- If A → B and B → C (poly-time reductions), then A → C.
For each: True or False, with a 1–2 line justification (Unit 1 exam format).
Show solution
- False. No restriction beyond: I solvable ⇔ f(I) solvable, g recovers a solution, f and g poly time (Nov 10 Q&A).
- False. Unknown. We don't know how to; doing so would prove P = NP (Nov 10 Q&A: “We don't know yet”).
- True. A problem we can solve in poly time can be verified by solving it (KT 8.10).
- False. NP-hard problems “don't have to be search problems” (e.g. optimization Max-SAT, ILP).
- False. “They very much depend on A and B.”
- True. Everything in NP reduces to it (KT 8.12; Nov 10 lecture).
- True. Compose: fBC∘fAB and gAB∘gBC are poly time (KT 8.9). Polynomials compose to polynomials.
9.6 Decision vs search (low priority) ⚑ Flagged in lecture · I57
Textbooks (KT, MU) mostly use decision problems (“is there an independent set of size k?”). This course uses search (“find it”). For self-reducible problems like independent set they are equally hard. Binary search on k finds the optimum size with O(log n) decision calls (KT §8.1), and deleting vertices one at a time while the answer stays the same recovers a set (derived; the lecture left it “for your own entertainment”).
- Find the size of a maximum independent set with O(log n) calls.
- Then find an actual maximum independent set with polynomially many calls.
Show solution
- Binary search on k ∈ [0, n] (KT §8.1).
- Let α be the max size. For each vertex v in turn: if G − v still has an independent set of size α, delete v permanently (some optimum avoids it); otherwise keep it. At the end every remaining vertex is needed, so the remaining graph is an independent set of size α. That's n more calls. (Derived argument; the lecture left this as an exercise.)
To show B is NP-hard, which direction do you reduce?
A NP-hard, A → B, B ∈ P. Conclusion?
Is every NP-hard problem in NP?
Is knapsack in NP? Knapsack-search?
Does f have to be injective?
10 · SAT, Max-SAT, 2-SAT and 3-SAT
Nov 10 lecture + board pp. 3–5 · LP4 §1, §9–13 · KT 8.2, 8.4
- prove Max-SAT (and ILP) NP-hard via SAT → Max-SAT → ILP
- build a 2-SAT implication graph, find SCCs, decide satisfiability
- split a long clause into 3-literal clauses and prove both directions
10.1 SAT and its variants
SAT. Input: a Boolean formula in CNF, an AND of clauses, each an OR of literals (a variable or its negation). Output: a satisfying assignment, or “no”. SAT is very expressive (the professor's example is encoding a class timetable), and Cook–Levin says it's NP-hard. Variants from the board: Max-SAT (maximize the number of satisfied clauses), k-SAT (at most k literals per clause), exact-k-SAT (exactly k). KT's 3-SAT means “exactly 3”, and it pads short clauses with extra forced-false variables (textbook only). Padding to “exactly k” with all sign patterns of fresh variables is problem 10.10.
10.2 Why is Max-SAT hard? (predicted exam question) ⚑ Flagged in lecture · I32
The professor: “Max-SAT is hard. Why? (Maybe I'll ask this on the exam; I'm telling you before the other section.)” The answer is a two-line reduction SAT → Max-SAT.
f: give the same formula φ (m clauses) to Max-SAT. g: take the returned assignment a. If a satisfies all m clauses, output a; otherwise output “no”.
⇔: φ is satisfiable ⇔ the maximum number of satisfiable clauses is m ⇔ the optimal a satisfies everything. If φ is unsatisfiable, no assignment satisfies all m, so we correctly answer “no”. Everything besides the black box is linear time. A poly-time Max-SAT algorithm would solve SAT, so Max-SAT is NP-hard.
Then ILP is hard too: Max-SAT → ILP (the formulation in §6.3), so SAT → Max-SAT → ILP. “The moment we break continuity and go to a discrete space of integer values, we go nuts.”
Show solution
Reduce SAT → Max-SAT (SAT is NP-hard by Cook–Levin).
f: given a CNF formula φ with m clauses, pass the same φ to Max-SAT. Identity: poly time.
⇔ and g: run Max-SAT to get an assignment a maximizing the number of satisfied clauses. Output a if it satisfies all m clauses, otherwise “no”. If φ is satisfiable, the maximum is m, so a satisfies everything and we return a satisfying assignment. If φ isn't satisfiable, no assignment satisfies all m, so a doesn't and we correctly say “no”. Checking the count is linear time. So a poly-time Max-SAT algorithm would solve SAT, and Max-SAT is NP-hard.
(Max-SAT is not in NP as an optimization problem, so it is NP-hard, not NP-complete.)
Show solution
f: variables yᵢ (one per Boolean variable) and zⱼ (one per clause), all in {0,1}; maximize Σzⱼ subject to zⱼ ≤ Σi∈Cⱼ⁺ yᵢ + Σi∈Cⱼ⁻(1 − yᵢ). Size O(n + m) variables and m constraints: poly.
Correctness: for 0/1 y, the RHS is 0 exactly when every literal of Cⱼ is false, which forces zⱼ = 0. Otherwise zⱼ can be 1, and maximization sets it. So the ILP optimum equals the max number of satisfiable clauses, achieved at y = the assignment. g: read xᵢ = T iff yᵢ = 1. Chain: SAT → Max-SAT → ILP, so ILP is NP-hard.
10.3 2-SAT is in P: implication graph + SCCs ⚑ Flagged in lecture · I43 I44
Intuition. “Every time I see pairs of elements together, I think there's a graph.” A 2-clause is really two implications.
Encoding: (a ∨ b) ≡ (¬a → b) ∧ (¬b → a). Build a directed graph on the 2n literals with two edges per clause. An edge u → v means “if u is true, v must be true”.
Observation: all literals in the same strongly connected component get the same truth value (paths both ways force equal values). So if some x and ¬x share an SCC, the formula is unsatisfiable.
Lecture's decision rule: compute SCCs (linear time). The formula is satisfiable ⇔ no x shares an SCC with ¬x. The lecture says the assignment details are “not that important for this class”; the GR2 video gives them video:
Full algorithm (GR2 video). (0) Unit clauses: while some clause is a single literal a, set a true, delete every clause containing a, and delete ¬a from the other clauses (an empty clause means NO). Afterwards every clause has exactly 2 literals. (1) Build the implication graph: 2n vertices, 2m edges. (2) Find SCCs; if some x and ¬x share one, output NO. (3) Take a sink SCC S and set all its literals true. Its complement S̄ = {¬ℓ : ℓ ∈ S} is a source SCC, and it becomes all false. Remove S and S̄ and repeat. Total O(n + m). (Processing SCCs in reverse topological order and making a literal true when its SCC comes after its negation's is the same rule.)
Why step 3 is safe. An implication u → v is broken only by u = T, v = F. S is a sink, so nothing leaves the true set S. S̄ is a source, so nothing enters the false set S̄. The key fact “S sink ⇒ S̄ source” follows from path symmetry: every clause gives its two edges as a pair, so a path α ⇝ β always comes with a path ¬β ⇝ ¬α. Proof: problem 10.13 ⚑ OMS video (extra) · I77 I78.
- List the 8 edges of the implication graph.
- Find the SCCs. Is f satisfiable?
- Give a satisfying assignment.
Show solution
- (x1∨x2): ¬x1→x2, ¬x2→x1. (x1∨¬x3): ¬x1→¬x3, x3→x1. (¬x2∨¬x4): x2→¬x4, x4→¬x2. (¬x3∨x4): x3→x4, ¬x4→¬x3.
- No cycles, so all 8 SCCs are single vertices. No x shares an SCC with ¬x, so f is satisfiable.
- Assigning in reverse topological order (x = T iff x's SCC comes after ¬x's) gives x1 = T, x2 = T, x3 = F, x4 = F. Check: (T∨T), (T∨T), (F∨T), (T∨F). All true.
Show solution
Edges: ¬x1→x2, ¬x2→x1, ¬x1→¬x2, x2→x1, x1→x2, ¬x2→¬x1, x1→¬x2, x2→¬x1. Then x1 → x2 → ¬x1 and ¬x1 → x2 → x1, so x1 and ¬x1 are in the same SCC. In fact all four literals form 1 SCC. Same SCC ⇒ same truth value, but x1 and ¬x1 can't be equal. Unsatisfiable.
Show solution
(a) The clause is false only when a = b = F. Exactly then ¬a → b fails (T → F) and ¬b → a fails. In all other cases both implications hold.
(b) Each edge u → v is an implication that a satisfying assignment must respect: if u is true then v is true. If u and v are in the same SCC, there are paths u ⇝ v and v ⇝ u, so u true ⇒ v true and v true ⇒ u true. Equal values.
(c) x and ¬x always have opposite values, so they can't be in one SCC of a satisfiable formula. (The converse, that otherwise it's satisfiable via the topological-order assignment, is the video's lemma.)
- Apply unit-clause elimination step by step until no unit clause is left. Write each intermediate formula.
- Is f satisfiable? Give the assignment.
- Why is the formula after one elimination step satisfiable ⇔ the formula before it is?
- What should the algorithm do if elimination ever produces an empty clause?
Show solution
- Unit (¬x₁): set x₁ = F. Delete clauses containing ¬x₁ (the unit clause itself) and delete the false literal x₁ from (x₁ ∨ x₄): f′ = (x₃ ∨ ¬x₂) ∧ (x₄) ∧ (¬x₄ ∨ x₂) ∧ (¬x₃ ∨ x₄). Unit (x₄): set x₄ = T, delete (x₄) and (¬x₃ ∨ x₄), shrink (¬x₄ ∨ x₂) to (x₂): (x₃ ∨ ¬x₂) ∧ (x₂). Unit (x₂): set x₂ = T, giving (x₃). Unit (x₃): set x₃ = T, giving the empty formula.
- Yes: x₁ = F, x₂ = T, x₃ = T, x₄ = T (the only satisfying assignment).
- The unit clause (a) can only be satisfied by making a true, so every satisfying assignment does that. Clauses containing a are then already satisfied (safe to delete), and the literal ¬a is false (safe to delete from its clauses). Nothing else changes.
- An empty clause can't be satisfied, so output NO. (This case is my addition; the video only shows the satisfiable path.) Otherwise, after elimination every clause has exactly 2 literals and the SCC algorithm takes over.
- Show: if there is a path α ⇝ β, then there is a path ¬β ⇝ ¬α.
- Show: if S is an SCC then S̄ is an SCC; and if S is a sink SCC then S̄ is a source SCC.
- Assume no x shares an SCC with ¬x. The algorithm sets every literal of a sink SCC S true (so S̄ false), removes S ∪ S̄ and repeats. Show every clause that contains a literal of S ∪ S̄ is satisfied.
Show solution
- Write the path as α = γ₀ → γ₁ → ⋯ → γℓ = β. Each edge γᵢ → γᵢ₊₁ comes from the clause (¬γᵢ ∨ γᵢ₊₁), which also contributes the edge ¬γᵢ₊₁ → ¬γᵢ. Following these edges backwards gives ¬β = ¬γℓ → ⋯ → ¬γ₀ = ¬α.
- For α, β ∈ S there are paths both ways, so by (a) there are paths ¬β ⇝ ¬α and ¬α ⇝ ¬β: all of S̄ lies in one SCC. Applying the same argument to that SCC shows it can't contain anything outside S̄, so S̄ is exactly an SCC. If an edge u → ¬α entered S̄ from outside (u ∉ S̄, α ∈ S), then by (a) the edge α → ¬u would exist, with ¬u ∉ S: an edge leaving S. A sink has none, so S̄ has no incoming edges: it is a source.
- A clause with a literal in S is satisfied, because that literal is true. A clause (ℓ ∨ b) with ℓ ∈ S̄ gives the edge ¬ℓ → b with ¬ℓ ∈ S. S is a sink, so b ∈ S, and b is true. S ≠ S̄ because no x shares an SCC with ¬x, so no literal gets both values. Removing S ∪ S̄ (closed under negation) leaves exactly the implication graph of the remaining clauses, with the same SCCs, so we can repeat. Total time O(n + m).
10.4 3-SAT is NP-hard: clause splitting ⚑ Flagged in lecture · I45 I46
Intuition. Long clauses are the only thing separating SAT from 3-SAT. Chop each long clause into a chain of 3-literal clauses glued by fresh variables. The professor calls it “a trick… out of the magician's hat”.
f: for a clause C = (x₁ ∨ ⋯ ∨ xₖ) with k > 3, add new variables y₁, …, yk−3 and replace C by C′ = (x₁ ∨ x₂ ∨ y₁) ∧ (¬y₁ ∨ x₃ ∨ y₂) ∧ (¬y₂ ∨ x₄ ∨ y₃) ∧ ⋯ ∧ (¬yk−3 ∨ xk−1 ∨ xₖ). Clauses with ≤ 3 literals stay as they are. Each clause uses its own fresh y's.
(⇒) If C is true, some xᵢ is true and satisfies its clause in the chain. Set the y's before that clause to T and those after to F: every clause to the left contains a true y, and every clause to the right contains a true ¬y.
(⇐) If every xᵢ is false, clause 1 forces y₁ = T, clause 2 then forces y₂ = T, …, and the last clause (¬yk−3 ∨ xk−1 ∨ xₖ) is false. So C′ is unsatisfiable. (Brute-force checked for k = 4…8 in calc.py.)
Size and g: k − 2 clauses and k − 3 new variables per long clause, so linear in the length of the formula. In terms of n and m (NP2 video video): each clause adds at most n new variables and clauses, so O(nm) in the worst case, which is polynomial ⚑ OMS video (extra) · I75. g restricts the assignment to the original variables. Together with “3-SAT ∈ NP” (check an assignment), 3-SAT is NP-complete.
Show solution
(a) C′ = (x1 ∨ x2 ∨ y1) ∧ (¬y1 ∨ x3 ∨ y2) ∧ (¬y2 ∨ x4 ∨ y3) ∧ (¬y3 ∨ x5 ∨ y4) ∧ (¬y4 ∨ x6 ∨ x7).
(b) ⇒: let xᵢ be a true literal. Its clause is satisfied. Set y₁, …, yj = T for every y appearing before xᵢ's clause and the rest F. Each clause to the left contains some yₜ = T, and each clause to the right contains some ¬yₜ with yₜ = F. ⇐ (contrapositive): if all xᵢ are false, clause 1 forces y₁ = T, then clause 2 forces y₂ = T, …, then the last clause (¬yk−3 ∨ xk−1 ∨ xₖ) is false. So C′ is unsatisfiable.
(c) k − 2 = 8 clauses and k − 3 = 7 new variables. Each clause of length k becomes O(k) clauses, so the total size is linear in the formula. g: restrict the 3-SAT assignment to the original variables.
Show solution
Each middle clause needs three slots: the connector ¬yt−1 from the previous clause, one original literal, and the connector yₜ to the next. With two slots you can't both chain the clauses and carry an original literal, so the equivalence breaks. That's consistent with 2-SAT ∈ P (unless P = NP, no such reduction exists).
Show solution
In NP: the candidate solution is an assignment; the verifier evaluates each clause in linear time. NP-hard: SAT → 3-SAT by clause splitting (10.6). Clauses with ≤ 3 literals are copied unchanged, longer ones are split, and the original variables' values are kept.
Show solution
Reduce 3-SAT → k-SAT with f = identity: every 3-SAT formula already has ≤ 3 ≤ k literals per clause, so it is a k-SAT input with exactly the same satisfying assignments (g = identity). Polynomial trivially. (Reducing to a more general problem is often this easy. Compare VC → Set Cover.)
Show solution
In NP. Given an assignment, check each clause in O(1) time: O(m).
Reduce 3-SAT → Exact-4-SAT. Let φ be a 3-SAT formula (every clause has 1 to 3 literals; remove repeated literals, and drop clauses containing both x and ¬x since they're always true).
f: for each clause C with j < 4 literals, create 4 − j fresh variables z and replace C by the 24−j clauses “C ∨ (one sign pattern of the z's)”. For example, a 3-literal clause (a ∨ b ∨ c) becomes (a ∨ b ∨ c ∨ z) ∧ (a ∨ b ∨ c ∨ ¬z). Clause counts per original clause: 1 → 8, 2 → 4, 3 → 2 (literals → clauses). So there are ≤ 8m clauses and ≤ 3m new variables: polynomial (linear).
(⇒) If an assignment satisfies φ, keep it and set the z's arbitrarily. Every new clause contains an original clause C, which is true.
(⇐) Take an assignment satisfying f(φ) and suppose some original C is false under it. Among C's padded copies, pick the one whose z-literals are all false under this assignment (choose each sign opposite to that z's value). That copy has every literal false: contradiction. So every C is true, and the assignment restricted to the original variables satisfies φ.
g: drop the z's. Linear. Together with “in NP”, Exact-4-SAT is NP-complete.
Shape lesson (§12.2): “same problem, extra size condition” ⇒ reduce from the original and pad.
Show solution
In NP: check that the assignment satisfies φ (O(nm)) and count the true variables (O(n)).
SAT → Stingy SAT: f(φ) = (φ, n) where n is the number of variables. ⇔: every assignment has ≤ n true variables, so φ has a satisfying assignment ⇔ (φ, n) has a stingy one. g = identity. f and g are linear.
Shape lesson (§12.2): a generalization of a known hard problem (extra parameter k) ⇒ set the parameter so it becomes the special case.
Why is Max-SAT hard?
When is a 2-SAT formula unsatisfiable?
A k-literal clause splits into how many clauses and new variables?
2-SAT assignment rule (GR2)?
Why doesn't splitting give 2-SAT?
11 · Graph reductions: Independent Set, Clique, Vertex Cover, Matching
Nov 12 lecture (transcript; that day's board isn't in the folder) · KT 8.1–8.2
- build the 3-SAT → IS graph and prove both directions
- move between IS, Clique (complement graph) and VC (complement set)
- explain why reductions don't preserve approximation, and how matching → flow proves easiness
11.1 3-SAT → Independent Set ⚑ Flagged in lecture · I47 I48 I49 I50
Intuition (lecture). Make the literals the vertices, so that an independent set is a choice of literals to make true. We need exactly one chosen literal per clause and no contradictions. Both needs become edges: a clique inside each clause (“don't be greedy: pick exactly one”), and an edge between every x and ¬x (the students' suggestion in class).
Input transformation f. For φ with m clauses (≤ 3 literals each), G has one vertex per literal occurrence. Join every pair in the same clause (clause cliques), and every complementary pair x, ¬x across clauses. Set k = m. Size: vertices ≤ 3m, clause edges ≤ 3m, complement edges at worst quadratic. “Linear in this, quadratic in that, therefore polynomial. Done.”
(⇒) φ satisfied ⇒ pick one true literal per clause. They are in different clauses (no clique edge) and can't be complementary (x and ¬x can't both be true). Independent, size m.
(⇐) An independent set of size m has exactly one vertex per clause (the cliques allow at most one) and never x with ¬x. Set those literals true, others arbitrary. The assignment is consistent and satisfies every clause.
Recovery g. One pass: chosen literals become true, unassigned variables get anything. Linear time.
- List the vertices, the clause-clique edges, the complement edges, and k.
- Find an independent set of size k and the assignment it gives.
- Can S = {x@C1, ¬x@C2, z@C3} be chosen? Why not?
Show solution
- Vertices (one per literal occurrence): x@C1, ¬x@C2, y@C2, ¬y@C3, z@C3, x@C3, so 6 vertices. Clause edges: ¬x@C2–y@C2; ¬y@C3–z@C3, ¬y@C3–x@C3, z@C3–x@C3. Complement edges: x@C1–¬x@C2, ¬x@C2–x@C3, y@C2–¬y@C3. Total 7 edges. k = m = 3.
- S = {x@C1, y@C2, z@C3} is independent and |S| = 3 ⇒ x = T, y = T, z = T. Check: (T), (F ∨ T), (F ∨ T ∨ T). All satisfied.
- No: x@C1 and ¬x@C2 are joined by a complement edge (a contradiction: x and ¬x both “true”).
Show solution
In NP. Given S, check |S| ≥ k and that no edge joins two vertices of S: O(|V| + |E|).
Reduce 3-SAT → IS. Transformation f. For a formula φ with m clauses (≤ 3 literals each), make one vertex per literal occurrence. Join all vertices of the same clause (clause cliques), and join every pair of complementary literals x, ¬x, in any clauses. Set k = m. Size: ≤ 3m vertices, ≤ 3m clause edges, ≤ (3m)² complement edges. Polynomial.
(⇒) If φ is satisfiable, pick one true literal per clause. The m picked vertices are in different clauses (no clique edge), and no two are complementary because both would have to be true (no complement edge). So we get an independent set of size m.
(⇐) If G has an independent set S of size m, it has exactly one vertex per clause (the cliques allow at most one) and never both x and ¬x. Set those literals true and the remaining variables arbitrarily. This is consistent and satisfies every clause.
Recovery g. Given S, read off the assignment as above in linear time. If IS reports no set of size m, φ is unsatisfiable by (⇒).
Show solution
(a) Fine: the clause is satisfied more than once, but the independent set takes exactly one vertex per clause, because the clause clique allows at most one. (b) Prevented by the complement edge y–¬y: such an S isn't independent. (c) The cliques cap |S| at one per clause, so m is the maximum possible, and reaching m forces one true literal in every clause.
11.2 Independent Set ↔ Clique (complement graph)
Mechanism. Ĝ has the same vertices and exactly the missing edges: e ∈ Ê ⇔ e ∉ E. S is independent in G ⇔ S is a clique in Ĝ (“no edges inside S” becomes “all edges inside S”). Reduction IS → Clique: (G, k) ↦ (Ĝ, k), same set back. Computing Ĝ takes O(n²), and Clique ∈ NP (check all pairs), so Clique is NP-complete. The professor's aside: more generally, finding a copy of a given graph H inside G is hard; Clique is the special case H = Kk.
Show solution
(a) For u, v ∈ S: uv ∉ E ⇔ uv ∈ Ê. “No pair in S is an edge of G” is the same as “every pair in S is an edge of Ĝ”.
(b) In NP: check all pairs of K are edges (O(k²)). NP-hard: IS → Clique with f(G, k) = (Ĝ, k), which takes O(n²) to complement. By (a), G has an independent set of size k ⇔ Ĝ has a clique of size k, and g returns the same set.
(c) Yes: complementing twice gives back G, so Clique → IS is the same map. (Both are NP-complete, so reductions exist both ways.)
11.3 Independent Set ↔ Vertex Cover ⚑ Flagged in lecture · I52 I53
Mechanism. S is independent ⇔ V∖S is a vertex cover. (⇒) No edge has both ends in S, so every edge has an end in V∖S. (⇐) If two vertices of S were adjacent, that edge would have no end in V∖S. Reductions both ways: (G, k) ↦ (G, n − k). So Vertex Cover is NP-complete. A student asked whether the complement of a vertex cover is always an independent set: yes, that's (⇐).
Show solution
(a) ⇒: for any edge uv, u and v are not both in S, so one of them is in V∖S. ⇐: if u, v ∈ S were adjacent, neither endpoint would be in V∖S, contradicting the cover.
(b) IS → VC: (G, k) ↦ (G, n − k). G has an independent set of size ≥ k ⇔ a vertex cover of size ≤ n − k; g = complement. VC → IS: (G, k) ↦ (G, n − k), symmetric.
(c) Yes, that's the ⇐ direction of (a).
11.4 Reductions don't preserve approximation ⚑ Flagged in lecture · I54
Question from class: we have a 2-approximation for vertex cover and an exact IS ↔ VC correspondence. Do we get an approximation for IS? No. The lecture's star example points the right way: the IS optimum is almost everything, so any slack in the cover eats the independent set. The clean counterexample (from the transcript editor's note) is a perfect matching. Min VC = n/2, so a 2-approximation may return all n vertices, whose complement is ∅, while the max IS is n/2.
Show solution
No. Take a perfect matching on n vertices (n/2 disjoint edges). Min VC = n/2, so a 2-approximation may legally return all n vertices. Its complement is ∅, but the max IS is n/2. The ratio is 0: no constant factor survives. (In the star, the min VC is just the center, and the max IS is everything else.) Exact reductions preserve optimal solutions, not approximation ratios.
11.5 Reductions prove easiness too: bipartite matching → max flow ⚑ Flagged in lecture · I55
Mechanism. From the bipartite graph (V₁, V₂, E): add s and t, add s → u for every u ∈ V₁, orient the edges V₁ → V₂, add v → t for every v ∈ V₂, and give every edge capacity 1. Take an integral max flow (Ford–Fulkerson gives one when capacities are integers). The saturated middle edges M = {(u,v) : f(u,v) = 1} form a maximum matching.
Claim: M is a matching. Suppose two edges of M leave the same u ∈ V₁. Then the flow out of u is ≥ 2, but u's only incoming edge is s → u with capacity 1. This violates conservation. The same argument applies at v ∈ V₂ (only one outgoing edge, v → t). Conversely, a matching gives a flow of equal value (one unit along s → u → v → t per edge). So max flow = max matching, and bipartite matching ∈ P.
Show solution
(a) Add s and t; s → u for all u ∈ V₁; direct each edge u → v (V₁ to V₂); v → t for all v ∈ V₂; all capacities 1. Poly time.
(b) Suppose two edges of M share u ∈ V₁. Then the flow out of u is ≥ 2, but the only edge into u is s → u, with capacity 1, so the flow in is ≤ 1. This contradicts conservation. The same argument at v ∈ V₂ (only one edge out, v → t) rules out sharing a V₂ endpoint. Conversely, each matching edge gives a unit path s → u → v → t, so max flow value = max matching size. (Uses that max-flow algorithms return integral flows when capacities are integers.)
(c) Matching → Max-Flow, and Max-Flow ∈ P, so bipartite matching ∈ P. Reductions to easy problems prove easiness.
11.6 Textbook-only (KT 8.1, 8.4): Set Cover, Set Packing, Circuit-SAT
VC → Set Cover (KT 8.6): universe = edges; for each vertex, the set of its incident edges. Same k. IS → Set Packing (KT 8.7): the same sets; disjoint sets ⇔ non-adjacent vertices. Circuit-SAT (KT 8.13) is KT's first NP-complete problem (any poly-time certifier becomes a poly-size circuit), and KT reduces Circuit-SAT → 3-SAT gate by gate. KT's chain 3-SAT → IS → VC → Set Cover gives the NP-completeness of all four (KT 8.16).
Show solution
f: U = E (the edges); for each vertex i, Sᵢ = the edges incident to i; same k. A vertex cover {i₁, …, iℓ} touches every edge ⇔ Si₁ ∪ ⋯ ∪ Siℓ = E. So covers of size ≤ k correspond exactly. Poly time; g maps the chosen sets back to their vertices. Since VC is NP-hard, Set Cover is NP-hard (and in NP: check the union).
- Since 3-SAT → IS, the reduction IS → SAT given by Cook–Levin is just the 3-SAT → IS construction run backwards.
- S is a maximum independent set of G if and only if V∖S is a minimum vertex cover of G.
- A 2-approximation for vertex cover yields a 2-approximation for independent set via complements.
- In 3-SAT → IS, if the graph has an independent set of size m, the formula is satisfiable.
- Reducing bipartite matching to max flow shows bipartite matching is NP-hard.
- Clique and Independent Set reduce to each other.
For each: True or False, with a 1–2 line justification (Unit 1 exam format).
Show solution
- False. Reductions in the other direction don't have to be inverses (Nov 12 Q&A). The 3-SAT → IS graphs are very special (small cliques plus links).
- True. Complements: sizes add to n, so maximizing |S| minimizes |V∖S|.
- False. Perfect-matching example: the 2-approximate cover can be all of V, leaving ∅.
- True. That's the ⇐ direction.
- False. It shows matching is in P (reduction TO an easy problem). Hardness would need a reduction FROM a hard problem.
- True. Both via the complement graph Ĝ.
3-SAT → IS: vertices, edges, k?
IS ↔ VC map?
Counterexample: VC 2-approx ⇏ IS approx?
What does matching → max-flow prove?
12 · Writing a reduction: template and decision guide
Combines the professor's three steps (input transformation, the ⇔, solution recovery) with “show it's in NP”, in the shape of the Exam 1/Exam 2 official solutions (short prose, every step justified in a sentence).
- write any NP-completeness proof in the five-part format
- pick a good source problem from the shape of the new problem
12.1 The five-part template ⚑ Flagged in lecture · I47 I48 I49 I51 I06
Why a template. The lecture says proofs need not be “super detailed as long as we have the right ideas”, but every part must be there. The ⇔ is non-negotiable (“we have to check both directions”). Polynomial time takes two counting sentences.
1. B ∈ NP. “Given a candidate solution S, check [property] in O(·) time.” (Skip this if only NP-hardness is asked.)
2. Choose a known NP-hard A and reduce A → B. Say the direction explicitly: “We reduce A to B.”
3. Input transformation f. Describe exactly what f(I) is (graph, number, formula). Then two sentences on size: “f(I) has O(·) vertices and O(·) edges, so f runs in polynomial time.”
4. Correctness: I has a solution ⇔ f(I) has a solution. (⇒) From a solution of I, build one of f(I). (⇐) From a solution of f(I), build one of I. The contrapositive is allowed for either direction.
5. Recovery g + conclusion. “Given S for f(I), output g(S) = … in linear time. If B has no solution, neither does I, by (⇒). Hence B is NP-hard (NP-complete with step 1).”
- Wrong direction (new → known).
- Only (⇒). The second student in problem 12.5.
- f that secretly solves A (exponential time).
- No recovery g in the search setting.
- Forgetting “in NP” when NP-complete is asked.
- Claiming NP-complete for an optimization problem (Max-SAT is NP-hard).
Show solution
1. In NP: given M, check |M| ≤ k and that every edge has an endpoint in M: O(|V| + |E|).
2. Known hard problem: Independent Set (NP-hard via 3-SAT). Reduce IS → VC.
3. f: (G, k) ↦ (G, n − k). O(1) extra work beyond copying G.
4. ⇔: (⇒) if S is independent with |S| ≥ k, then V∖S covers every edge (an edge inside S would contradict independence), and |V∖S| ≤ n − k. (⇐) If M is a cover with |M| ≤ n − k, then V∖M is independent (an edge inside it would be uncovered), and |V∖M| ≥ k.
5. Poly + recovery: f and g (g(M) = V∖M) are linear time. If VC answers “none”, IS has none either, by (⇒).
Show solution
Student 1 reduced 2-SAT → IS. That only says IS is at least as hard as 2-SAT, which tells us nothing about 2-SAT (wrong direction). Hardness needs a known hard problem → 2-SAT, which would imply P = NP since 2-SAT ∈ P.
Student 2 proved only (⇒). Without (⇐), a clique of size m in Ĝ might not come from any satisfying assignment, so the black box's answer can't be trusted for “no” instances. Both directions are required.
12.2 Which known problem do I reduce from? ⚑ Flagged in lecture · I42
The professor doesn't expect “an illumination”, so the source is usually one of the lecture problems. Match the shape of the new problem (genres from KT §8.10):
| If the new problem looks like… | Reduce from | Typical gadget |
|---|---|---|
| Choose ≥ k objects, some pairs conflict (packing) | Independent Set | objects = vertices, conflicts = edges (often almost identity) |
| Choose ≤ k objects that together cover everything (covering) | Vertex Cover (or Set Cover†) | edges = things to cover; vertex = the set of its edges |
| Find k mutually compatible / all-pairs-connected objects | Clique (or IS on Ĝ) | complement graph |
| Boolean constraints, or nothing above fits | 3-SAT | one gadget per variable and per clause: “pick one literal per clause, no contradictions” (KT's view (b)) |
| A more general version of a known hard problem (more literals allowed, weights, extra options) | that special case | identity map, or set the extra parameter so it becomes the special case (3-SAT → k-SAT, VC → Set Cover†, SAT → Stingy SAT in 10.12) |
| An optimization (“maximize satisfied / chosen”) version | its feasibility version | same instance; the optimum is “everything” ⇔ feasible (SAT → Max-SAT) |
| Same problem with an extra size condition (exactly half, even n, …) | the original problem | pad with isolated or universal vertices, or with fresh variables in all sign patterns (problems 12.2, 10.10) |
| Want to show the problem is easy | (reduce to) max-flow, SCC, LP | build a network or graph (matching → flow, 2-SAT → SCC) |
† = textbook only (KT).
Show solution
In NP: check size n′/2 and independence.
Reduce IS → HALF-IS. Input (G, k), n = |V|. Assume 2 ≤ k ≤ n (k = 1 is trivial).
f: If 2k ≤ n, add n − 2k isolated vertices: n′ = 2n − 2k, target n′/2 = n − k = k + (n − 2k). If 2k > n, add t = 2k − n universal vertices, adjacent to every vertex and to each other: n′ = 2k, target k. Linear/quadratic size.
⇔ (case 2k ≤ n): (⇒) an independent set of size k in G plus all n − 2k isolated vertices is independent, of size n − k. (⇐) An independent set of size n − k in G′ uses at most n − 2k new vertices, so it has ≥ k vertices of G, which are independent in G.
⇔ (case 2k > n): (⇒) an independent set of size k in G is still independent in G′ (no new edges among old vertices). (⇐) Any independent set containing a universal vertex has size 1 < k (k ≥ 2), so an independent set of size k in G′ lies entirely in G.
g: drop the added vertices. Poly time throughout.
Show solution
f: U = E; for each vertex v, Sv = the set of edges incident to v; same k. Poly.
⇔: Su ∩ Sv ≠ ∅ ⇔ the edge uv exists (an edge is in both incidence sets exactly when it joins u and v). So a family {Sv : v ∈ T} is pairwise disjoint ⇔ T is independent, and sizes match. g: T = the indices of the chosen sets. In NP: check pairwise disjointness. So Set Packing is NP-complete.
- Choose ≥ k servers so that no two conflicting servers are both chosen.
- Choose ≤ k cameras so that every corridor (a pair of rooms) is watched by a camera in one of its rooms.
- Find k people who all know each other.
- A Boolean constraint problem with ≤ 4 literals per clause.
- Satisfy as many constraints as possible.
Show solution
- Independent Set (a packing problem with conflicts as edges): identity-like map.
- Vertex Cover (covering edges with vertices).
- Clique (or IS on Ĝ).
- 3-SAT (identity, since 3 ≤ 4), or SAT with clause splitting.
- SAT → “max” version with the same instance (Max-SAT style: satisfiable ⇔ the optimum satisfies all).
The five parts?
Most common lost points?
13 · Said in lecture but not on the slides
From the transcripts: student Q&A, board-only remarks, and corrections. Each is also in §1 with its exact quote.
| What was said | Where | Why it matters |
|---|---|---|
| Karger is called the watermelon algorithm (“for obvious reasons”) | Oct 29, Nov 3 | An exam may use that name |
| Deterministic global min-cut: max-flow for every pair (s, t), keep the best | Oct 29 (student discussion) | Min-cut ∈ P, unlike Max-Cut |
| “At random” means uniform unless stated. Weighted sampling (probability ∝ importance) is possible | Nov 3 | Read problem statements literally |
| You can't “run until success” for min-cut, since minimality can't be checked. Keep the smallest of N | Nov 3 | Boosting argument structure |
| A Piazza question: why care about a 1-in-a-million success chance? Answer: boosting | Nov 3 | Motivation for p⁻¹ polynomial |
| Max-Cut is hard (“tell your friends”). Min-cut is easy | Nov 3 | T/F trap |
| Derandomized max-cut: different vertex orders give different cuts, all ≥ m/2 | Nov 3 recap | T/F trap |
| “Maybe I'll ask this on the exam”: why Max-SAT is hard | Nov 10 | Problem 10.1 |
| Reduction direction “is a great multiple-choice question”; shortest path → SAT, not necessarily back | Nov 10 Q&A | §9.4 |
| f need not be injective; f and g depend on A and B | Nov 10 Q&A | Definitions |
| The K2026 fake reduction: f must connect to g | Nov 10 | Why recovery matters |
| Knapsack as seen in class is not a search problem (optimality can't be verified, the DP is pseudo-polynomial) | Nov 10 | Class definition of NP |
| NP-hard problems need not be search problems | Nov 10 | NP-hard ⇏ NP |
| “We don't know yet” whether NP-hard problems can be solved in poly time | Nov 10 Q&A | Wording on T/F |
| 2-SAT assignment order: “watch the video; it's not that important for this class” | Nov 10 | Know SCCs + the unsatisfiability test |
| Why the splitting trick fails for 2-SAT (needs 3 slots) | Nov 10 | Problem 10.7 |
| HW6 reductions are “practice for the exam” | Nov 10 | Get HW6 |
| Clause cliques: “don't be greedy: pick exactly one”; complement edges were the students' fix for picking y and ¬y | Nov 12 | 3-SAT → IS details |
| Proof style: contrapositive allowed; “we don't need super detailed proofs”; two sentences for poly time | Nov 12 | How to write answers |
| The reverse reduction IS → SAT exists (Cook–Levin) but isn't the inverse construction | Nov 12 Q&A | T/F trap |
| IS/VC duality “would be a great final exam question” (as an LP duality question) | Nov 12 | Final, but know S ⇔ V∖S |
| Approximation factors don't transfer through reductions (star example) | Nov 12 | §11.4 |
| Medical residency matching as the origin of bipartite matching algorithms | Nov 12 | Context only |
| Self-reducibility: decision ⇒ search “for your own entertainment” | Nov 12 | Low priority |
| A reduction promised on the final; a practice exam will be posted before Exam 3 | Nov 12 | Scope |
| Corrections to the slides: board 1 − (1−p)N+1 should be N; the max-cut bound needs m even (odd m: 1/(m+1)); the LP4 ¾ proof as stated is incomplete | Nov 3 / LP4 editorial notes | See ⚠ items in §1 |
15 · HW5 decoded: the techniques, and exam-style re-skins
homeworks/hw5.pdf (Problem Set 5, problems 19–22). Exam 2 re-skinned two HW4 problems, so this section treats HW5 as the long-question bank ⚑ Past exam / HW · I63 I64. Every problem here is fully solved: the four HW5 originals (15.1–15.4, solutions in exam-answer form, written by me since there are no official solutions) and ten exam-style re-skins (15.5–15.14).
- count min cuts (and α-small cuts) with a probabilistic argument
- prove “below average ⇒ above average” and build tight exact-k-SAT examples
- analyze randomized rounding + repetition for covering problems (O(log) approximation)
- analyze a repetition protocol: what is hidden, and how fast a cheater is caught
15.1 Counting min cuts, and stopping the watermelon early (#19) ⚑ Past exam / HW · I66
Why it exists. The Karger bound is a statement about one fixed cut, but it holds for every min cut simultaneously. Because a run outputs only one cut, those probabilities can't add up to more than 1, and that bounds how many min cuts can exist. This is a pure probabilistic-method counting argument. The second idea (HW5's “stop your watermelon earlier!”) handles cuts that are only approximately minimum. They are more fragile, so we stop contracting before the risky last steps.
Counting. Distinct min cuts Δ₁, …, Δt. The events “run returns Δᵢ” are disjoint, each has probability ≥ 2/(n(n−1)), so t·2/(n(n−1)) ≤ 1.
Stopping early. If t supervertices remain and the cut is intact, every supervertex has degree ≥ λ (it's a cut of G), so there are ≥ tλ/2 edges. A cut C with |C| ≤ αλ is hit with probability ≤ αλ/(tλ/2) = 2α/t. Stop at r = 2α supervertices (2α an integer): Pr[C survives] ≥ ∏t=r+1n(1 − 2α/t) = 1/C(n, 2α), which telescopes (checked by script for many n, k). Then output a uniformly random cut of the r-vertex graph. One of its 2r−1 − 1 cuts is C. Combining with disjointness: #α-small cuts ≤ C(n,2α)·22α−1 = Oα(n2α).
- The counting needs disjoint events (one output per run). Don't sum over overlapping events.
- Why the degree bound still holds: every supervertex corresponds to a cut of the original G, so its degree is ≥ λ in every contracted graph. That keeps the edge count ≥ tλ/2.
- Stop at about 2α, not at 2: running all the way gives ∏(1 − 2α/t) down to t = 3, which hits zero or goes negative when 2α ≥ 3.
- The final random cut costs a factor 2r−1, a constant for fixed α.
For this problem, let G = (V, E) be a connected, undirected graph. A min cut is a partition (S, T) of the vertices such that the number of edges from S to T is minimized.
- Show that a graph has at most O(n²) min-cuts. (There are many ways to do this, a probabilistic argument is desired. The Watermelon algorithm may be of inspiration.)
- Let α > 1 be a constant. A cut is α−small if it has size at most α|(S, T)|, for any min-cut (S, T). Prove that the number of α−small cuts is Oα(n2α). (Hint: Stop your watermelon earlier!)
Show solution
- Part 1: Karger's theorem is about each fixed min cut. Can two different cuts be returned by the same run?
- Part 2: redo the Karger product for a fixed cut of size ≤ αλ. The per-step bound becomes 2α/t. Stop when 2α supervertices remain, then output a random cut of what's left.
Full solution (what to write)
1. At most n(n−1)/2 min cuts. Let λ be the min-cut size and let Δ₁, …, Δt be all the distinct min cuts. Fact (lecture, §4.2): for any fixed min cut Δ, one run of the contraction algorithm outputs Δ with probability ≥ 2/(n(n−1)). (Reason: with j supervertices left and Δ intact, every supervertex has degree ≥ λ, so there are ≥ jλ/2 edges and Pr[contract an edge of Δ] ≤ λ/(jλ/2) = 2/j. Multiply ∏j=3n(1 − 2/j) = 2/(n(n−1)).)
Let Aᵢ = “the run outputs Δᵢ”. A run outputs exactly one cut, so the events Aᵢ are disjoint. Therefore 1 ≥ Pr[A₁ ∪ ⋯ ∪ At] = Σᵢ Pr[Aᵢ] ≥ t · 2/(n(n−1)), so t ≤ n(n−1)/2 = O(n²). (Tight: the cycle Cₙ has exactly this many, problem 15.5.)
2. α-small cuts. First assume 2α is an integer and set r = 2α (so r ≥ 3, because α > 1). Fix a cut C = (S, T) with |C| ≤ αλ. Modified algorithm: contract uniformly random edges until r supervertices remain; then output a uniformly random partition of those r supervertices into two non-empty sides.
Contraction phase. Suppose j supervertices remain and no edge of C has been contracted yet. Each supervertex X is one side of a cut (X, V∖X) of the original G, so deg(X) ≥ λ, and the multigraph has ≥ jλ/2 edges. The next edge is in C with probability ≤ αλ/(jλ/2) = 2α/j. So Pr[C survives until r remain] ≥ ∏j=r+1n(1 − r/j) = ∏j=r+1n(j − r)/j = (n − r)!·r!/n! = 1/C(n, r).
Final phase. If C survived, each side of C is a union of supervertices, so C is one of the 2r−1 − 1 two-sided partitions of the r supervertices. It is chosen with probability 1/(2r−1 − 1) ≥ 2−(r−1).
Counting. Pr[output = C] ≥ 1/(C(n, 2α)·22α−1) for every α-small C. The events “output = C” are disjoint over different C, so #α-small cuts ≤ C(n, 2α)·22α−1 ≤ n2α·22α−1/(2α)! = Oα(n2α).
If 2α is not an integer, stop at r = ⌈2α⌉. Using ln(1 − x) ≥ −x/(1 − x): 1 − 2α/j ≥ exp(−2α/(j − 2α)), and Σj=r+1n 1/(j − 2α) ≤ 1 + ln n (first term ≤ 1, the rest ≤ ∫ ds/(s − 2α)). So the survival probability is ≥ e−2α·n−2α, and the count is ≤ e2α·2r−1·n2α = Oα(n2α). (Both product bounds are checked numerically in calc.py.)
- (5) Let λ be the min-cut size. Using only “one run of the contraction algorithm returns any fixed min cut with probability ≥ 2/(n(n−1))”, prove that G has at most n(n−1)/2 distinct min cuts.
- (3) Show the bound is tight: give a graph on n vertices with exactly n(n−1)/2 min cuts.
Show solution
- Let Δ₁, …, Δt be the distinct min cuts and Aᵢ the event “the run returns Δᵢ”. A run returns exactly one cut, so the Aᵢ are disjoint. So 1 ≥ Pr[A₁ ∪ ⋯ ∪ At] = Σ Pr[Aᵢ] ≥ t·2/(n(n−1)), giving t ≤ n(n−1)/2 = O(n²).
- The cycle Cₙ: λ = 2, and removing any 2 of the n edges splits it into two arcs, a cut of size 2. That's C(n,2) = n(n−1)/2 min cuts. (Enumeration for C₅: 10 min cuts, each returned with probability exactly 1/10.)
- Count the α-small cuts exactly (in terms of n), and evaluate for n = 10.
- Compare with the early-stop bound C(n, 2α)·22α−1 and with n2α. Is the O(n2α) growth rate tight here?
Show solution
- Every cut of a cycle cuts an even number of edges, and any even-size edge set defines a cut (go around the cycle alternating sides). So the α-small cuts number C(n,2) + C(n,4). For n = 10: 45 + 210 = 255.
- Bound: C(10,4)·2³ = 1,680 ≥ 255 ✓. Since C(n,4) = Θ(n⁴) = Θ(n2α), the exponent 2α can't be improved in general. (For n = 20: 5035 cuts vs bound 38,760.)
- (4) Show that while Δ is intact and t supervertices remain, the next contraction avoids Δ with probability ≥ 1 − 2/t.
- (5) Conclude Pr[Δ survives until r supervertices remain] ≥ r(r−1)/(n(n−1)). Evaluate for n = 10, r = 4.
- (4) Now let C be a cut of size ≤ αλ with 2α an integer k. Show Pr[C survives until k supervertices remain] ≥ 1/C(n, k).
- (4) Finish: output a uniformly random cut of the k-vertex graph (there are 2k−1 − 1). Conclude that there are O(n2α) α-small cuts.
(You may use earlier parts even if you didn't prove them.)
Show solution
- Every supervertex alone is a cut of G, so it has degree ≥ λ. So there are ≥ tλ/2 edges and Pr[pick a Δ-edge] ≤ λ/(tλ/2) = 2/t.
- Chain rule over t = n, n−1, …, r+1: ∏ (1 − 2/t) = ∏ (t−2)/t, which telescopes to (r−1)r/((n−1)n). For n = 10, r = 4: 2/15. (r = 2 recovers 2/(n(n−1)).)
- Same argument with |C| ≤ αλ: Pr[pick a C-edge] ≤ αλ/(tλ/2) = k/t. ∏t=k+1n (t−k)/t = k!(n−k)!/n! = 1/C(n,k).
- If C survived, it is one of the 2k−1 − 1 cuts of the remaining graph, and a uniform choice picks it with probability ≥ 2−(k−1). So Pr[output C] ≥ 1/(C(n,k)·2k−1). The events “output C” are disjoint for different C, so the number of α-small cuts is ≤ C(n,k)·2k−1 ≤ n2α·22α−1 = Oα(n2α). (Non-integer 2α: stop at ⌈2α⌉ and bound ∏(1 − 2α/t) by cα·n−2α using ln(1 − x) ≥ −x − x²; the same conclusion holds.)
15.2 Exact-k-SAT: expectation, “below ⇒ above”, tight examples (#20) ⚑ Past exam / HW · I68 I65
Why it exists. A random assignment's expected score is an average over all assignments. Averages force spread: if anything is below the average, something must be above it. And when every clause has exactly k distinct literals, the average is exactly (1 − 2−k)m, which gives a clean target.
Expectation: an exactly-k clause fails for one of its 2k settings ⇒ E[W] = (1 − 2−k)m (linearity).
Below ⇒ above: E[W] = (1/2ⁿ)Σₐ W(a). If W(a₀) < E[W] and no W(a) exceeded E[W], the average would be < E[W]. The MU Lemma 6.2 argument, made strict.
Tight example: take all 2k sign patterns on k variables. Each assignment falsifies exactly one clause (the one whose literals are all false under it), so it scores exactly (1 − 2−k)·2k. Brute-force verified for k = 2 and k = 4.
Recall the Max-SAT problem. The input is a Boolean formula in conjunctive normal form and you wish to output an assignment of the variables that satisfy the maximum number of clauses. This problem is (famously) known to be NP-hard.
- Consider an input of MAX-Exact-3SAT (every clause is the disjunction of exactly three literals). Show that a random assignment will satisfy at least 87.5% of the clauses in expectation.
- Show that for MAX-Exact-3SAT, if there is an assignment that satisfies strictly less than 87.5% of the clauses, then there is another assignment that satisfies strictly more than 87.5% of the clauses. Hint: this is the Probabilistic Method idea discussed in lecture.
- Give an example of an input of MAX-Exact-3SAT such that every assignment satisfies exactly 87.5% of the clauses. Hint: 2³ = 8.
Show solution
- (a) One indicator per clause. A clause with 3 distinct variables fails for exactly one of its 8 settings (§6.2).
- (b) The expectation is an average over the 2ⁿ equally likely assignments. If one term is below the average and none is above, what happens to the average? (§5.1)
- (c) Look at the figure in §15.2 (k = 2, 4 clauses) and do the same with k = 3.
Full solution (what to write)
(a) Assume (as “exactly three literals” means) the three literals of each clause are on distinct variables. Let a random assignment set each variable T/F independently with probability ½. For clause Cⱼ let Yⱼ = 1 if Cⱼ is satisfied. Cⱼ is false only if all three literals are false, which has probability (½)³ = 1/8. So E[Yⱼ] = 7/8. The number of satisfied clauses is W = Σⱼ Yⱼ. By linearity of expectation (no independence between clauses needed), E[W] = 7m/8 = 87.5% of m.
(b) The random assignment is uniform over all 2ⁿ assignments, so E[W] = (1/2ⁿ)·Σₐ W(a) = 7m/8: the expectation is the plain average of W over all assignments. Suppose some a₀ has W(a₀) < 7m/8, and suppose for contradiction that no assignment has W(a) > 7m/8. Then every term is ≤ 7m/8 and one is strictly smaller, so Σₐ W(a) < 2ⁿ·7m/8, i.e. E[W] < 7m/8. Contradiction. Hence some a₁ has W(a₁) > 7m/8.
(c) Take the 8 clauses on x₁, x₂, x₃ with all 2³ sign patterns: (x₁∨x₂∨x₃), (x₁∨x₂∨¬x₃), …, (¬x₁∨¬x₂∨¬x₃). Fix any assignment a. A clause is false under a iff each of its literals is false, which fixes the sign of every literal (use xᵢ if aᵢ = F, ¬xᵢ if aᵢ = T). So exactly one of the 8 clauses is false, and every assignment satisfies exactly 7 of 8 = 87.5%. (Brute-force checked in calc.py.)
- (4) Show a uniformly random assignment satisfies 15/16 of the clauses in expectation.
- (5) Show: if some assignment satisfies strictly fewer than 15m/16 clauses, then some assignment satisfies strictly more.
- (4) Construct a formula on which every assignment satisfies exactly 15/16 of the clauses.
- (2) A formula has m = 20 such clauses. How many clauses can you guarantee to satisfy simultaneously?
Show solution
- A clause fails only when all 4 literals are false: one of the 16 equally likely settings of its variables. E[Wⱼ] = 15/16, and by linearity E[W] = 15m/16.
- E[W] is the average of W(a) over all 2ⁿ equally likely assignments a: (1/2ⁿ)Σₐ W(a) = 15m/16. If W(a₀) < 15m/16 and every W(a) ≤ 15m/16, the average would be strictly below 15m/16, a contradiction. So some W(a) > 15m/16. (Exactness matters: with exactly 4 distinct literals, E is exactly 15m/16.)
- All 16 clauses on x₁…x₄ with every sign pattern. Each assignment falsifies exactly the one clause whose literals are all false under it, so it satisfies 15 of 16.
- Some assignment achieves ≥ the mean 75/4, and counts are integers, so ≥ 19.
Show solution
(a) (x₁∨x₂) ∧ (x₁∨¬x₂) ∧ (¬x₁∨x₂) ∧ (¬x₁∨¬x₂): every assignment satisfies 3 of 4 (see the §15.2 figure). It's also the unsatisfiable 2-SAT example from §10.3. (b) A random assignment averages 3m/4, so some assignment reaches at least that. (c) ≥ ⌈15/4⌉ = 4.
15.3 Randomized rounding for covering problems + repetition (#21) ⚑ Past exam / HW · I67 I64
Why it exists. Covering problems (hitting set, set cover, vertex cover) have ILPs of the form “min cost, every constraint has total ≥ 1”. Rounding each variable to 1 with probability equal to its LP value satisfies each constraint with probability ≥ 1 − 1/e, the same AM–GM argument as MAX-SAT (§6.4). But a cover must satisfy every constraint. So we repeat the rounding and take the union: each round multiplies a miss probability by ≤ 1/e. That's the boosting idea from §4.3, applied per constraint, plus a union bound over constraints.
One round: a constraint with variables summing to ≥ 1 in the LP is missed with probability ∏(1 − x*ᵢ) ≤ (1 − 1/k)k ≤ 1/e (independence, AM–GM, constraint, 1 − x ≤ e−x).
t rounds: Pr[constraint j missed] ≤ e−t. Union bound over the M constraints: Pr[not feasible] ≤ M e−t, which is ≤ 1/4 for t = ⌈ln(4M)⌉.
Cost: E[cost of one round] = Σ x*ᵢ = LP* ≤ OPT (minimization), so E[cost of t rounds] ≤ t·OPT = O(log M)·OPT.
Repeat-until-covered version: T = number of rounds needed. Pr[T > t] ≤ M e−t, so E[T] = Σ Pr[T > t] ≤ ⌈ln M⌉ + 1/(1 − 1/e). E[cost] = LP*·E[T], because round r's cost is independent of the event that round r is reached.
- Minimization: LP* ≤ OPT (opposite of MAX-SAT). The ratio argument uses E[cost] ≤ t·LP* ≤ t·OPT.
- One round is not a cover. Each constraint is only satisfied with probability ≥ 1 − 1/e.
- The union bound is over constraints (elements for set cover, sets for hitting set). Use the right count in ln(·).
- For the stopping-time version, don't just write E[cost] = E[T]·LP* without the independence sentence.
- HW4 / Exam 2 used deterministic rounding (threshold 1/b or 1/k). HW5 is the randomized version. Know both and which guarantee each gives.
Input: Subsets S₁, S₂, …, Sm ⊂ {1, 2, …, n}. Output: the smallest set S such that S ∩ Sk ≠ ∅ for all 1 ≤ k ≤ m. (S does not have to be one of the Sᵢ.)
- Write an instance of ILP that is equivalent to Hitting-Set.
- As in class, consider the corresponding LP relaxation. Let {x*ᵢ} be an optimal of the relaxation. Define xᵢ = 1 with probability x*ᵢ, else 0 (i.e.: with probability 1 − x*ᵢ), and set S = {i | xᵢ = 1}. Compute P(S ∩ Sⱼ ≠ ∅). Briefly justify your answer.
- Conclude that P(S ∩ Sⱼ ≠ ∅) ≥ 1 − 1/e. You can use the Arithmetic Mean-Geometric Mean inequality as well as others we used in class without proof.
- Consider the following algorithm: sample S repeatedly as in part (b), take the union until you hit all sets. Show that it is enough to do O(ln(m)) rounds in expectation. Hint: use (c) to bound the probability that a set Sᵢ is not covered after ln(m) rounds. Conclude using linearity of expectation.
- Prove this algorithm yields a ln(m)−Approximation algorithm for Hitting-Set.
Show solution
- (a) One 0/1 variable per element i; one covering constraint per set Sⱼ (compare HW4 #18 and Exam 2 Q4).
- (b)–(c) This is the MAX-SAT rounding lemma (§6.4) with the clause replaced by Sⱼ: a product, then AM–GM, then the constraint, then (1 − 1/k)k ≤ 1/e.
- (d) After t rounds, Pr[Sⱼ still missed] ≤ e−t. Count missed sets with linearity; for E[#rounds] use E[T] = Σ Pr[T > t].
- (e) Each round adds expected cost Σ x*ᵢ = LP* ≤ OPT.
Full solution (what to write)
(a) ILP. Variable xᵢ ∈ {0, 1} for each element i = 1, …, n (xᵢ = 1 means i ∈ S).
minimize Σᵢ xᵢ subject to Σi ∈ Sⱼ xᵢ ≥ 1 for every j = 1, …, m, and xᵢ ∈ {0, 1}.
Equivalence: if S is a hitting set, its indicator vector satisfies every constraint (S contains some i ∈ Sⱼ) and has objective |S|. Conversely a feasible 0/1 vector gives S = {i : xᵢ = 1}, which meets every Sⱼ, with |S| equal to the objective. So the optima are equal. The LP relaxation replaces xᵢ ∈ {0, 1} by 0 ≤ xᵢ ≤ 1. It is a relaxation of a minimization, so LP* = Σᵢ x*ᵢ ≤ OPT.
(b) The xᵢ are rounded independently. S misses Sⱼ exactly when xᵢ = 0 for every i ∈ Sⱼ, so P(S ∩ Sⱼ = ∅) = ∏i∈Sⱼ(1 − x*ᵢ) and P(S ∩ Sⱼ ≠ ∅) = 1 − ∏i∈Sⱼ(1 − x*ᵢ).
(c) Let k = |Sⱼ| ≥ 1. AM–GM on the k non-negative numbers 1 − x*ᵢ: ∏i∈Sⱼ(1 − x*ᵢ) ≤ ((1/k)Σi∈Sⱼ(1 − x*ᵢ))k = (1 − (1/k)Σi∈Sⱼx*ᵢ)k ≤ (1 − 1/k)k ≤ e−1. The middle step uses the LP constraint Σi∈Sⱼx*ᵢ ≥ 1; the last uses 1 − y ≤ e−y. So P(S ∩ Sⱼ ≠ ∅) ≥ 1 − 1/e ≈ 0.632.
(d) Rounds use fresh coins, so they are independent. For a fixed j, P(Sⱼ missed by all of the first t rounds) = ∏ over rounds of P(that round misses Sⱼ) ≤ e−t. Let Xt = number of sets not yet hit after t rounds. By linearity, E[Xt] = Σⱼ P(Sⱼ missed) ≤ m·e−t, which is ≤ 1 for t = ⌈ln m⌉. Let T = number of rounds until every set is hit. Then P(T > t) = P(Xt ≥ 1) ≤ E[Xt] ≤ m e−t (Markov). With t₀ = ⌈ln m⌉ (so m e−t₀ ≤ 1): E[T] = Σt≥0 P(T > t) ≤ t₀ + Σs≥0 m e−t₀−s ≤ ⌈ln m⌉ + 1/(1 − 1/e) ≈ ⌈ln m⌉ + 1.582 = O(ln m).
(e) The output is the union of the T samples, so its size is ≤ Σr=1T|S(r)|. One round has E|S(r)| = Σᵢ x*ᵢ = LP*. Whether round r happens (T ≥ r) depends only on rounds 1, …, r − 1, so it is independent of S(r). Hence E[cost] ≤ Σr≥1 E[|S(r)|·1{T ≥ r}] = Σr≥1 LP*·P(T ≥ r) = LP*·E[T] ≤ (⌈ln m⌉ + 1.582)·OPT. The output is always a valid hitting set and its expected size is within a factor ln m + O(1) = O(ln m) of OPT: an O(ln m)-approximation (in expectation).
- (4) Write an ILP with a variable yⱼ per set, and its LP relaxation. Why is LP* ≤ OPT?
- (5) Pick each set Sⱼ independently with probability y*ⱼ. For an element e in sets Sj₁, …, Sjk, show Pr[e covered] ≥ 1 − 1/e.
- (4) Repeat the rounding t times independently and take the union. Show Pr[some element uncovered] ≤ n·e−t. Pick t so this is ≤ 1/4.
- (4) Show E[# sets chosen] ≤ t·OPT.
- (3) Conclude: with probability ≥ 1/2 the output is a cover of size ≤ 4t·OPT = O(log n)·OPT.
Show solution
- min Σⱼ yⱼ s.t. Σj: e∈Sⱼ yⱼ ≥ 1 for every e ∈ U, yⱼ ∈ {0,1} (ILP), or 0 ≤ yⱼ ≤ 1 (LP). Every cover is LP-feasible with the same value and the LP minimizes over a superset, so LP* ≤ OPT.
- e is missed only if none of its k sets is picked: Pr = ∏ᵢ (1 − y*jᵢ) (independence). AM–GM: ≤ (1 − (Σᵢ y*jᵢ)/k)k ≤ (1 − 1/k)k ≤ 1/e, using the constraint Σ ≥ 1 and 1 − x ≤ e−x.
- Rounds are independent: Pr[e missed by all t] ≤ (1/e)t. Union bound over n elements: ≤ n·e−t. t = ⌈ln(4n)⌉ gives ≤ 1/4 (n = 100: t = 6; n = 1000: t = 9).
- One round picks Sⱼ with probability y*ⱼ, so E[# sets in a round] = Σ y*ⱼ = LP* ≤ OPT. The union of t rounds has at most the sum of the round sizes, so by linearity E ≤ t·LP* ≤ t·OPT.
- Markov: Pr[size > 4t·OPT] ≤ 1/4. Union bound with (c): Pr[not a cover, or too big] ≤ 1/2. Repeat to boost (§4.3).
- Show Pr[T > t] ≤ n·e−t, and conclude E[T] ≤ ⌈ln n⌉ + 1/(1 − 1/e) = O(log n).
- Show E[total # sets picked] ≤ E[T]·LP*. (Careful: T depends on the rounds.)
Show solution
- T > t means some element is uncovered after t rounds: ≤ n e−t by 15.10(c). Tail sum: E[T] = Σt≥0 Pr[T > t] ≤ Σt<⌈ln n⌉ 1 + Σs≥0 n e−⌈ln n⌉−s ≤ ⌈ln n⌉ + Σs≥0 e−s = ⌈ln n⌉ + 1/(1 − 1/e). (1/(1 − 1/e) ≈ 1.582; n = 100 gives E[T] ≤ 6.58.)
- Let Cᵣ be the number of sets picked in round r, so the total is Σᵣ Cᵣ·1{T ≥ r}. The event {T ≥ r} (“not done after r − 1 rounds”) depends only on rounds 1…r−1, so it is independent of Cᵣ, and E[Cᵣ·1{T ≥ r}] = LP*·Pr[T ≥ r]. Summing: E[total] = LP*·Σᵣ Pr[T ≥ r] = LP*·E[T] ≤ (ln n + O(1))·OPT. That is an O(log n)-approximation in expectation.
Show solution
U = {1}, S₁ = ⋯ = Sₖ = {1}, y* = (1/k, …, 1/k): LP* = 1 = OPT. Element 1 is covered unless all k coins fail: Pr = 1 − (1 − 1/k)k (k = 3: 19/27). Threshold rounding picks all k sets (each y* = 1/k ≥ 1/k), a cover of size k = k·OPT. That's Exam 2 Q4's tight example. The two methods trade a factor k (deterministic, frequency k) against O(log n) (randomized, any instance).
15.4 Challenge protocols: zero knowledge + repetition (#22)
Why it exists. A prover wants to convince a verifier that G is 3-colorable without revealing a coloring. Each round, randomness on both sides does a job. The prover's random color permutation hides which coloring she has (zero knowledge). The verifier's random edge gives a cheater a fixed chance of getting caught (soundness). One round only catches a cheater with probability ≥ 1/m, so we repeat. This is the boosting algebra of §4.3 with the goal flipped: drive the cheater's success to 0.
Zero knowledge (honest prover): the revealed pair is (π(c₁), π(c₂)) with c₁ ≠ c₂ fixed and π uniform over the 3! permutations. Every ordered pair of distinct colors appears for exactly one π, so the pair is uniform over the 6 possibilities regardless of C. Fresh π each round makes rounds independent, so nothing accumulates.
Soundness (cheater): each round's commitment is some coloring, and since G isn't 3-colorable it has a monochromatic edge. The verifier picks it with probability ≥ 1/m, so a round is passed with probability ≤ 1 − 1/m. Independent rounds give ≤ (1 − 1/m)N ≤ e−N/m.
Rounds: e−N/m ≤ ε ⇔ N ≥ m ln(1/ε). An honest prover always passes: one-sided error, Monte Carlo.
- The bound uses “≥ 1 bad edge out of m”, hence 1/m, not “half the edges”.
- The rounds must be independent (fresh permutation and fresh commitment). Otherwise both soundness and zero knowledge can break (problem 15.14).
- Binding commitments are essential: if Raquel can change colors after the challenge, she always passes.
- The cheater's success is what you bound. The honest prover's acceptance probability is exactly 1.
Raquel knows a proper 3-coloring C of G and repeats N rounds: (1) choose a uniformly random permutation π of the three colors, C′(v) = π(C(v)); (2) commit to every vertex's color (perfectly hiding and binding); (3) Brito selects an edge {u, v} uniformly at random; (4) Raquel reveals the colors of u and v, and Brito accepts the round if they differ. Brito accepts only if he accepts all N rounds.
- Explain why Brito learns no information about Raquel's particular coloring C, beyond what is implied by the fact that G is 3-colorable (this is the Zero knowledge part). In particular, indicate the distribution of the two colors revealed in a round.
- Suppose G is not 3-colorable and has m = |E| edges (thus, every assignment C : V → {1, 2, 3} must assign the same color to the endpoints of at least one edge). Give an upper bound on the probability that Raquel passes all N rounds.
- Given 0 < ε < 1, determine how large N must be (in terms of m and ε) to guarantee that the probability of accepting a dishonest prover in part (b) is at most ε.
Show solution
- (a) The two colors are π(c₁), π(c₂) with c₁ ≠ c₂ fixed and π uniform over all 6 permutations. List the pairs that can come out and how often.
- (b) Whatever Raquel commits to in a round is some coloring, and it has a bad edge. What's the chance Brito picks it? Rounds use fresh coins.
- (c) Boosting algebra (§4.3) with the roles reversed: make (1 − 1/m)N ≤ ε using 1 − x ≤ e−x.
Full solution (what to write)
(a) In one round Brito sees: the commitments (perfectly hiding, so they reveal nothing), the edge {u, v} he chose himself, and the two opened colors (C′(u), C′(v)) = (π(c₁), π(c₂)), where c₁ = C(u) ≠ c₂ = C(v) because C is proper. For any ordered pair (d₁, d₂) of different colors there is exactly one permutation π with π(c₁) = d₁ and π(c₂) = d₂ (the third color must go to the remaining one). π is uniform over the 3! = 6 permutations, so the revealed pair is uniform over the 6 ordered pairs of distinct colors, each with probability 1/6. This distribution is the same for every proper coloring C and every edge. Brito could generate it himself (pick an edge, pick two distinct random colors) without talking to Raquel, so he learns nothing except that the endpoints differ, which is exactly what 3-colorability implies. A fresh π each round makes the rounds independent, so nothing builds up over N rounds.
(b) Fix a round. Because commitments are binding, they fix one assignment C′ : V → {1, 2, 3} before Brito picks the edge. G is not 3-colorable, so some edge e* is monochromatic under C′. Brito's edge is uniform over the m edges and independent of C′, so he picks e* (and rejects) with probability ≥ 1/m. Hence P(pass a round) ≤ 1 − 1/m, even conditioned on everything that happened in earlier rounds (Brito's coins are fresh). Multiplying over rounds: P(pass all N rounds) ≤ (1 − 1/m)N ≤ e−N/m.
(c) It suffices that e−N/m ≤ ε ⇔ N/m ≥ ln(1/ε) ⇔ N ≥ m ln(1/ε), so N = ⌈m ln(1/ε)⌉ works. (The exact minimum is ⌈ln ε / ln(1 − 1/m)⌉, slightly smaller.) Example: m = 15, ε = 10⁻³ gives N = 104 (exact minimum 101). An honest prover passes with probability 1: one-sided error.
- (4) What is the distribution of the two revealed colors in a round, for an honest prover?
- (4) If G is not bipartite, with m edges, bound the probability that Raquel passes all N rounds.
- (4) How many rounds guarantee cheating success ≤ ε? Evaluate for m = 15, ε = 10⁻³.
- (3) Is the overall test Las Vegas or Monte Carlo? One-sided or two-sided error?
Show solution
- The endpoints have different colors c₁ ≠ c₂, and π is uniform over the 2 permutations, so (π(c₁), π(c₂)) is (1,2) or (2,1), each with probability ½, whatever the coloring. Brito learns nothing beyond “the endpoints differ”.
- Any committed coloring of a non-bipartite graph has ≥ 1 monochromatic edge. Brito hits it with probability ≥ 1/m, so a round is passed with probability ≤ 1 − 1/m. Rounds are independent (fresh π, fresh commitment, fresh challenge), so all N pass with probability ≤ (1 − 1/m)N ≤ e−N/m.
- e−N/m ≤ ε ⇔ N ≥ m ln(1/ε). For m = 15, ε = 10⁻³: N = 104 (the exact minimum with (14/15)N ≤ 10⁻³ is 101).
- Monte Carlo (fixed N rounds, can wrongly accept) with one-sided error: an honest prover is always accepted, and only a cheater can slip through.
Show solution
(a) Zero knowledge fails: across rounds Brito sees colors under one fixed relabeling, so revealed edges stitch together into Raquel's actual coloring (up to one renaming). (b) Soundness fails: a single color is never “wrong”, so a cheater is never caught. (c) Soundness fails: after seeing {u, v}, Raquel just reveals two different colors, so every round passes even when G is not 3-colorable.
Why at most n(n−1)/2 min cuts?
Tight example for exact-k-SAT?
Set cover rounding: rounds and guarantee?
Protocol rounds for cheat probability ε?
16 · Select-ALL drill (Exam 2 format) ⚑ Past exam / HW · I60 I62
Exam 2's Q1 opened with “Select ALL statements that are always true” (5–6 points each) and said “a counterexample suffices for a false statement”. For every option: mark it, then write one line, with a counterexample for each false one.
Select ALL that apply.
Show solution
Correct: 1, 2, 4
- ✔ Two supervertices remain, which is a partition of V.
- ✔ The theorem, for each fixed Δ.
- ✘ Monte Carlo: it may return a non-minimum cut.
- ✔ p ≥ 2/(n(n−1)) ≥ 1/n² gives failure ≤ (1 − 1/n²)n² ln n ≤ e−ln n = 1/n.
Select ALL that apply.
Show solution
Correct: 1, 3
- ✔ Linearity, each edge ½.
- ✘ Counterexample: a triangle never has all 3 edges crossing.
- ✔ Probabilistic method (MU Lemma 6.2).
- ✘ Counterexample: a triangle (m/2 = 1.5 is not an integer); also a single edge (X ∈ {0, 1}).
Select ALL that apply.
Show solution
Correct: 1, 4
- ✔ Each nonempty clause has probability ≥ ½.
- ✘ Counterexample: (x) ∧ (¬x), where the expectation is 1 of 2.
- ✘ Only in expectation.
- ✔ Averaging argument with αₖ + βₖ ≥ 3/2.
Select ALL that apply.
Show solution
Correct: 1, 3
- ✔ Hardness flows forward.
- ✘ Counterexample: shortest path → SAT.
- ✔ Easiness flows backward.
- ✘ Counterexample: shortest path → SAT again.
Select ALL that apply.
Show solution
Correct: 1, 3
- ✔ Solve, then verify by solving.
- ✘ NP-hard problems need not be search problems.
- ✔ SCCs of the implication graph.
- ✘ NP-hard, but not in NP as an optimization problem, so not NP-complete.
Select ONE.
Show solution
Correct: 3
- ✘ Required.
- ✘ Required.
- ✔ Not required (Nov 10 Q&A).
- ✘ Required in the search setting.
Select ALL that apply.
Show solution
Correct: 1, 2, 4
- ✔ Both directions.
- ✔ Edges flipped.
- ✘ Counterexample: a perfect matching; the cover may be all of V.
- ✔ Complements: optimal sets correspond.
Select ALL that apply.
Show solution
Correct: 1, 2
- ✔ (1 − 1/m)N ≤ e−N/m.
- ✔ e−ln(1/ε) = ε.
- ✘ One-sided: honest provers always pass.
- ✘ The revealed colors would stitch together the coloring (15.14a).
17 · Mock exams A and B (exact Exam 2 layout, 70 minutes each) ⚑ Past exam / HW · I58 I61
Both copy Exam 2's skeleton: Q1 = 40 points ((a) 5 select-all, (b) 5 select-one, (c) 6 select-all, (d) 10 calculation, (e) 6 short proof, (f) 8 bounds), Q2 = 15, Q3 = 20, Q4 = 25. Long questions are re-skins of HW5 plus one reduction, following the §2.2 blueprint. Do them on the iPad (sections M and N of the PDF), timed, with only your two-page sheet.
17.1 Mock A
(a) (5 points) One run of the watermelon (contraction) algorithm on a connected multigraph with n vertices. Select ALL statements that are always true.
(b) (5 points) A is NP-hard, A reduces to B, and B ∈ P. What can we conclude?
(c) (6 points) Select ALL statements that are always true.
(d) (10 points) φ = (a ∨ b ∨ ¬c) ∧ (¬a ∨ c) ∧ (¬b ∨ ¬c). Build the 3-SAT → Independent Set graph G: give |V|, the number of clause edges and complement edges, and k. Exhibit an independent set of size k and the assignment it gives.
(e) (6 points) Prove Markov's inequality: X ≥ 0, a > 0 ⇒ Pr[X ≥ a] ≤ E[X]/a.
(f) (8 points) A MAX-SAT formula has m = 48 clauses. You compute that a uniformly random assignment satisfies 40 clauses in expectation, and the LP relaxation has optimal value 44. What are the strongest lower and upper bounds on OPT that follow? Justify briefly.
Show solution
(a) 2 and 3. (1 ✘: Monte Carlo. 4 ✘: the degree argument counts every edge with multiplicity, and the output must be a real cut.)
(b) 2: B ∈ P ⇒ A ∈ P, and A is NP-hard ⇒ everything in NP is in P.
(c) 1 and 4. (2 ✘: never needs independence. 3 ✘: needs X ≥ 0. Counterexample: X = ±1, a = 1 gives Pr = ½ > 0 = E[X]/a.)
(d) |V| = 7 (one per literal occurrence), clause edges 5 (a triangle for C1, one edge each for C2 and C3), complement edges 4 (a–¬a, ¬c–c, b–¬b, c–¬c), total 9, k = m = 3. An independent set of size 3: ¬c@C1, ¬a@C2, ¬b@C3 ⇒ a = b = c = F. Check: (F∨F∨T), (T∨F), (T∨T). ✓
(e) I = 1{X ≥ a} ≤ X/a pointwise (uses X ≥ 0). Take expectations: Pr[X ≥ a] = E[I] ≤ E[X]/a.
(f) 40 ≤ OPT ≤ 44. Lower: some assignment satisfies at least the mean 40 (probabilistic method). Upper: the LP relaxation of a maximization satisfies LP* ≥ OPT. (m = 48 and the ½-guarantee give only weaker bounds: OPT ≤ 48, OPT ≥ 24.)
- (5) Using the fact that one run of the contraction algorithm returns any fixed min cut with probability ≥ 2/(n(n−1)), prove that a graph has at most n(n−1)/2 min cuts.
- (8) Run the contraction algorithm until only r supervertices remain. Show a fixed min cut survives with probability ≥ r(r−1)/(n(n−1)). Hint: each supervertex has degree ≥ λ.
- (2) Construct a family of graphs with exactly n(n−1)/2 min cuts.
Show solution
(a) See 15.5(a): the events are disjoint and each has probability ≥ 2/(n(n−1)). (b) See 15.7(a)–(b): per step ≥ 1 − 2/t, telescoping to r(r−1)/(n(n−1)). (c) The cycles Cₙ (15.5b).
- (4) Write an ILP and its LP relaxation.
- (6) Round: pick each Sⱼ independently with probability y*ⱼ. Prove that every element is covered with probability ≥ 1 − 1/e. Hint: AM–GM.
- (5) Repeat t = ⌈ln(4n)⌉ times and take the union. Prove that the result fails to be a cover with probability ≤ 1/4.
- (5) Prove E[# sets] ≤ t·OPT, and conclude an O(log n)-approximation that succeeds with probability ≥ 1/2.
Show solution
Full solution: problem 15.10 (a)–(e).
- (4) Show HITTING-SET ∈ NP.
- (13) Reduce VERTEX COVER to HITTING-SET and prove the ⇔.
- (4) Argue polynomial time and explain how to recover a vertex cover from a hitting set.
- (4) HW4 gave a b-approximation for hitting set, where b = max |Sⱼ|. What does it give for vertex cover through your reduction? Does this contradict §11.4 (reductions don't preserve approximation)?
Show solution
- Given H: check |H| ≤ k and that each Sⱼ meets H, in O(Σ|Sⱼ|).
- f(G = (V, E), k): universe [n] = V, one set Se = {u, v} for each edge e = uv, same k. (⇒) A vertex cover M with |M| ≤ k contains an endpoint of every edge, i.e. M ∩ Se ≠ ∅ for all e: a hitting set of size ≤ k. (⇐) A hitting set H with |H| ≤ k meets every {u, v}, i.e. touches every edge: a vertex cover of size ≤ k.
- f writes one 2-element set per edge, O(n + m). g = identity (H itself is the cover). If HITTING-SET reports none, G has no cover of size ≤ k, by (⇒).
- All sets have size b = 2, so we get a 2-approximation for vertex cover. No contradiction: this reduction maps solutions to solutions with the same cost (VC is literally the special case b = 2), so ratios carry over. The §11.4 failure was for IS ↔ VC, where costs transform as k ↦ n − k.
17.2 Mock B
(a) (5 points) Select ALL statements that are always true.
(b) (5 points) To prove a new problem B is NP-hard using a known NP-hard problem A, you must show:
(c) (6 points) Select ALL statements that are always true.
(d) (10 points) f = (x1 ∨ x2) ∧ (¬x1 ∨ x3) ∧ (¬x3 ∨ ¬x2) ∧ (x2 ∨ x3) ∧ (¬x2 ∨ x1). Draw the implication graph (list the edges), find its SCCs, decide satisfiability, and give a satisfying assignment if one exists.
(e) (6 points) Prove: if X is a discrete random variable with E[X] = μ, then Pr[X ≥ μ] > 0.
(f) (8 points) The derandomized max-cut algorithm returns a cut of size 18 on a graph with m = 30 edges. What are the strongest lower and upper bounds on the maximum cut that follow? Justify briefly.
Show solution
(a) 1, 2, 3. (4 ✘: about 2ⁿ repetitions would be needed.)
(b) 2: FROM the known problem TO the new one.
(c) 1, 3, 4. (2 ✘: LP* ≥ OPT for a maximization.)
(d) Edges (two per clause, ¬a → b and ¬b → a): x1→x3, x2→¬x3, x2→x1, x3→¬x2, ¬x1→x2, ¬x1→¬x2, ¬x2→x1, ¬x2→x3, ¬x3→¬x1, ¬x3→x2. SCCs: {x1, ¬x2, x3} and {¬x1, x2, ¬x3}. No variable shares an SCC with its negation ⇒ satisfiable. The assignment rule (x true iff SCC(x) is later in topological order) gives x1 = T, x2 = F, x3 = T. Check: (T∨F), (F∨T), (F∨T), (F∨T), (T∨T). ✓
(e) If Pr[X ≥ μ] = 0, all mass is on values < μ, so μ = Σ x Pr[X = x] < μ Σ Pr[X = x] = μ, a contradiction.
(f) 18 ≤ OPT ≤ 30. Lower: a cut of size 18 exists. Upper: no cut exceeds m. The algorithm's guarantee (≥ m/2 = 15) is weaker than the observed 18, and “18 ≥ OPT/2” would only give OPT ≤ 36, weaker than 30. (Same trap as Exam 2 Q1(f): extra information can be useless.)
- (4) Show a random assignment satisfies 15/16 of the clauses of a MAX-Exact-4SAT formula in expectation.
- (7) Show that if some assignment satisfies fewer than 15/16 of the clauses, another satisfies more.
- (4) Construct a formula where every assignment satisfies exactly 15/16 of the clauses.
Show solution
Full solution: problem 15.8 (a)–(c).
- (5) Distribution of the revealed colors for an honest prover, and why that reveals nothing.
- (6) Bound the cheating probability after N rounds when G is not bipartite.
- (5) Rounds needed for cheating probability ≤ 10⁻⁶ when m = 40.
- (4) Classify the test: Las Vegas or Monte Carlo? One-sided or two-sided error?
Show solution
(a), (b), (d): see 15.13. (c) N ≥ m ln(10⁶) = 553 (exact minimum 546).
- (4) Show SET-COVER ∈ NP.
- (12) Reduce VERTEX COVER to SET-COVER and prove the ⇔.
- (4) Polynomial time and recovery.
- (5) Given that SET-COVER is NP-hard, why is the O(log n)-approximation of problem 15.10 still useful? What would an exact poly-time algorithm imply?
Show solution
- Check that the chosen sets number ≤ k and that their union is U: polynomial.
- f(G, k): U = E; for each vertex v, Sv = the set of edges incident to v; same k. (⇒) A cover M with |M| ≤ k touches every edge, so ∪v∈M Sv = E. (⇐) If ∪v∈T Sv = E with |T| ≤ k, every edge has an endpoint in T, so T is a vertex cover.
- |U| = m, n sets, total size 2m: linear. g maps chosen sets to their vertices. A “none” answer is correct by (⇒).
- No exact poly-time algorithm is known: one would give P = NP, since VC → SET-COVER and VC is NP-hard. So a polynomial-time algorithm with a provable O(log n) factor is the realistic goal: it always returns a valid cover whose expected size is within O(log n)·OPT, and it never needs to know OPT.