CS 6515/4540 · Exam 3 study notes

Unit 3: Randomization and Hardness · lectures Oct 29 → Nov 12 · exam Thursday Nov 19, 3:30 PM
How to use these notes Each concept follows the same order: why it exists, then the mechanism or proof, then a figure with a “how to read it” box, then a worked example, then traps, then ✍ check-yourself problems. Every ✍ problem is also in ipad_problems.pdf under the same number, with writing space and all solutions at the end. Solve it on the iPad first, then open “Show solution” here. ⚑ Flagged in lecture badges mark things the professor singled out; ⚑ Past exam / HW badges mark evidence from this semester's exams and homework; ⚑ OMS video (extra) badges mark content from the NP1/NP2/GR2 videos, which add to the lecture but never override it. Click the ID to see the quote.
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.

Still check Canvas for the Unit 3 practice exam ⚑ Flagged in lecture · I04. Exam 2's practice exam predicted the shape of the real questions (LP formulations, “give an example” parts, guided convexity chains) but not the questions themselves ⚑ Past exam / HW · I69.

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:

ItemStatusWhat 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✅ addedFormat 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 onlyShows that Exam 2 re-skinned HW4 #16 and #18 (§2.2).
Unit 3 practice exam + solutions (Canvas)❌ still missing ⚑ Flagged in lecture · I04Do 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 · I05Reductions drilled from the lecture ones (§10–§12, Mock A Q4, Mock B Q4).
OMS videos NP1, NP2, GR2 (extra-transcripts/)✅ added as extraUsed 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 missingKT 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.

DayBlocks (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
  • Learn 90 min: §1, §2.2, §3, §4, §15.1
  • Retrieve 75 min: 3.1–3.9, 4.1–4.9
  • HW5 drill 40 min: HW5 #19 (15.1) timed, closed notes; then compare with the full solution
Sat 14
220 min ≈ 3.7 h
§5–§6 (probabilistic method, rounding), §15.2–§15.3
  • Spaced review 20 min: redo Fri ★ misses, mixed order
  • Learn 75 min: §5, §6, §15.2, §15.3
  • Retrieve 75 min: 5.1–5.9, 6.1–6.9, 15.8, 15.10
  • HW5 drill 50 min: HW5 #20, #21 (15.2, 15.3) timed; check against the solutions
Sun 15
180 min ≈ 3.0 h
§15.4, §9 (P/NP, with the NP1 video additions)
  • Spaced review 20 min: Fri–Sat ★ misses
  • Learn 75 min: §15.4, §9
  • HW5 drill 25 min: HW5 #22 (15.4) timed + check
  • Retrieve 60 min: 9.1–9.11, 15.13
Mon 16
220 min ≈ 3.7 h
§10–§11 reductions (with the GR2/NP2 additions) + select-all drill
  • Spaced review 25 min: Karger + rounding ★ (mixed)
  • Learn 85 min: §10, §11
  • Retrieve 80 min: 10.1–10.12, 11.1–11.7
  • Retrieve 30 min: §16 select-all 16.1–16.8 (interleaved)
Tue 17
200 min ≈ 3.3 h
§12 template, Mock A
  • Spaced review 25 min: reductions + SAT ★
  • Learn 30 min: §12
  • Retrieve 45 min: 12.1–12.4, 15.5–15.7
  • Mock 100 min: Mock A: 70 min timed + 30 min grading
Wed 18
215 min ≈ 3.6 h
Mock B, note sheet, redo misses
  • Spaced review 25 min: all ★ marked ✗
  • Mock 100 min: Mock B (or Canvas practice exam): 70 + 30
  • Note sheet 45 min: build the two-page sheet
  • Retrieve 45 min: redo every miss from both mocks
Thu 19
65 min ≈ 1.1 h
Light retrieval only; nothing new after noon; exam 3:30 PM
  • Spaced review 45 min: blank-page 11.2 + 15.10
  • Note sheet 20 min: read your sheet once
Short on time? Keep every block marked Spaced review, HW5 and Mock, and in the Retrieve blocks do only the ★ problems. Cut reading first, never the mocks. If you have more time, add the “challenge” problems and a second pass of §16.

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:

TechniqueEvidenceHow 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 practiceAlso “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 fadingThe 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.
SleepEvidence 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.

SymbolMeaningWhere
n, mGraphs: 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−2the 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ⱼ, I0/1 indicators (edge e crosses, clause j satisfied, event happens)§3.3, §5, §6
ΦkE[final cut | placements of the first k vertices]§5.3
M*, OPTthe 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, gA 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.

The five that matter most (1) “Why is Max-SAT hard? Maybe I'll ask this on the exam” (I32). (2) Reduction direction is “a great multiple-choice question” (I33). (3) The exam is “randomization and this reduction business, plus the kind of conclusions we've drawn” (I02, I40). (4) HW6's reductions are “practice for the exam”, and a reduction is promised on the final (I05, I06). (5) The boosting principle: p⁻¹ polynomial ⇒ repeat polynomially often (I17).
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

I01direct exam signal
“That is not going to be on Exam 3, because it's two days before the exam and it blends a couple of topics.”
transcripts/clean/lecture2-np-reductions-sat.md · Course logistics (start of class)
What it changes: The Nov 17 lecture (approximation & hardness, TSP inapproximability) is out of scope. These notes don't teach it. → covered in the notes
I02direct exam signal
“The exam content is randomization and this reduction business, plus the kind of conclusions we've drawn.”
transcripts/clean/lecture3-np-complete-graph-problems.md · Exam logistics
What it changes: Coverage is Oct 29 through Nov 12: randomization plus reductions. Nothing says Exam 3 is cumulative, so Units 1–2 are out. The phrase “conclusions we've drawn” gets its own section (what a reduction preserves). → covered in the notes
I03direct exam signal
“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."”
transcripts/clean/lecture3-np-complete-graph-problems.md · Exam logistics
What it changes: Expect short-answer questions on the definitions of P, NP, NP-hard, and NP-complete, and on what follows from A → B. Drilled in §9.5 and the T/F sets. → covered in the notes
I04announcement
“I'll post the practice exam ahead of the exam so you have time to practice.”
transcripts/clean/lecture3-np-complete-graph-problems.md · Exam logistics
What it changes: The Unit 3 practice exam is not in your folder. Download it from Canvas. Until then, the mock exam here follows the Unit 1 practice-exam format. → covered in the notes
I05announcement
“Yes, homework 6 has reductions, as practice for the exam.”
transcripts/clean/lecture2-np-reductions-sat.md · Wrap-up
What it changes: HW6 is the closest thing to exam reductions, and it hasn't been released yet. When it is, add it and ask for a coverage round. Until then, the reduction problems here (§10–§12, both mocks) are built from the lecture reductions. → covered in the notes
I06direct exam signal
“I am putting a reduction on the final.”
transcripts/clean/lecture3-np-complete-graph-problems.md · Step 3: recovering the solution
What it changes: He said “final”, not Exam 3. Still, it is the clearest signal that writing a full reduction is a tested skill. Every reduction here is written in the full exam format. → covered in the notes
⚠ Says final, not Exam 3. Treated as a strong hint for Exam 3 too (HW6 is “practice for the exam”).
I07announcement
“3.30, 3.35 and go on till 4.45.”
~/gatech/grad-alg/exam1/grad-cheatsheet/Lec 8 Sec A.srt · 00:00:45 → 00:00:53 (Unit 1, co-instructor)
What it changes: Unit 1 ran in class, about 75 minutes. Superseded by the real Exam 2 (70 minutes, I58): the mocks are timed at 70 minutes. → covered in the notes
⚠ From the Unit 1 lecture, not stated for Exam 3.
I08announcement
“Bringing one page of notes is permitted.”
~/gatech/grad-alg/exam1/grad-cheatsheet/Practice_Exam_Unit_1_Solutions.pdf · Instructions (page 1)
What it changes: Unit 1 allowed one page, Exam 2 allowed two (I59). Still no calculators, so every number here has a hand-computable form. → covered in the notes
⚠ Unit 1 rule. Confirm for Exam 3 on Canvas.

Past exams and homework (evidence)

I58announcement
“Time: 70 minutes”
previous-exams/Exam2_SecA.pdf · Cover page
What it changes: The real Exam 2 (same instructors, this semester) ran 70 minutes for 100 points. Both mocks are timed at 70 minutes. → covered in the notes
I59announcement
“Bringing two pages of notes is permitted.”
previous-exams/Exam2_SecA.pdf · Instructions, item 2
What it changes: Exam 2 (and its practice exam) allowed two pages of notes, not the one page of Unit 1. §7 plus the reduction template plus the HW5 tools fit on two pages. → covered in the notes
⚠ Supersedes the Unit 1 “one page” rule (I08). Confirm for Exam 3.
I60answer expectations
“Select ALL statements that are always true.”
previous-exams/Exam2_SecA.pdf · Q1(a)
What it changes: Short-answer parts include select-all multiple choice (5–6 points each). Drilled in the select-all bank (§16) and the mocks. → covered in the notes
I61answer expectations
“You may use a stated claim from an earlier part even if you did not prove it.”
previous-exams/Exam2_SecA.pdf · Instructions, item 7
What it changes: Long questions are chains of parts. If you're stuck on (a), assume it and do (b) and (c). Never leave later parts blank. → covered in the notes
I62answer expectations
“a counterexample suffices for a false statement.”
previous-exams/Exam2_SecA.pdf · Q1 instructions
What it changes: For each false statement, have a tiny counterexample ready (triangle for dependent indicators, (x)∧(¬x) for 7/8, the perfect matching for VC → IS approximation, …). → covered in the notes
I63direct exam signal
“(This was a homework problem!)”
previous-exams/Exam2_SecA.pdf · Q3(b) hint
What it changes: Exam 2 Q3 was built on HW4 #16 (gradient descent, guided parts), and Q4 on HW4 #18 (hitting set, deterministic rounding) with the roles swapped (set cover, frequency k). Expect Exam 3's long questions to re-skin HW5. §15 does exactly that. → covered in the notes
I64direct exam signal
“Hitting Set via Deterministic Rounding”
~/algo-part2-notes/homeworks/hw4.tex · Problem 18
What it changes: HW4 #18: write the LP, round at x* ≥ 1/b, prove it hits every set, prove a b-approximation. Exam 2 Q4: the same proof for set cover with frequency k, plus “construct a tight instance”. The HW5 analogue is #21 (hitting set, randomized rounding), so the predicted exam version is randomized rounding for set cover (§15.3). → covered in the notes
I65answer expectations
“Construct a family of graphs for which the algorithm can return an independent set of”
previous-exams/Exam2_SecA.pdf · Q2(c)
What it changes: Each long question ended with a small “construct a tight example” part (star graph; three identical sets). HW5 #20(c) is the same move. Practice tight examples in §15. → covered in the notes
I66emphasis
“Hint: Stop your watermelon earlier!”
homeworks/hw5.pdf · Problem 19.2
What it changes: A new technique not in lecture: run Karger until 2α supervertices remain, then pick a random cut. That counts α-small cuts as O(n2α). Taught in §15.1. → covered in the notes
I67emphasis
“This problem walks you through another example of the use of randomized rounding.”
homeworks/hw5.pdf · Problem 21
What it changes: Randomized rounding on a covering problem plus repetition (O(ln m) rounds, ln m-approximation). Combines §6.4 with §4.3 boosting. Taught in §15.3. → covered in the notes
I68emphasis
“Hint: this is the Probabilistic Method idea discussed in lecture.”
homeworks/hw5.pdf · Problem 20(b)
What it changes: “Some assignment is below average ⇒ some assignment is above average” is the E[X] = μ lemma (§5.1). §15.2 covers it with tight examples. → covered in the notes
I69answer expectations
“Give an example of a graph G where the LP relaxation value is strictly more than the size of the maximum matching on G.”
previous-exams/Practice_Exam_2_Soln-1.pdf · Q2.2(b)
What it changes: The practice exam's “give an example” parts predicted the real exam's “construct an instance” parts, not specific questions. When the Unit 3 practice exam appears, use it for the shape of the questions. → covered in the notes
I79answer expectations
“What are the strongest lower and upper bound on the size of the minimum vertex cover that follows from this information?”
previous-exams/Exam2_SecA.pdf · Q1(f)
What it changes: An 8-point “strongest bounds on OPT” part with a useless extra fact (the matching). Rules for which side each fact bounds, plus the worked Exam 2 answer (10 ≤ OPT ≤ 20): §6.6, problem 6.12, M.1(f), N.1(f). → covered in the notes

Randomized algorithms: basics

I09student Q&A / posed question
“Question: Las Vegas or Monte Carlo? Do we always get a min-cut? No.”
transcripts/clean/lecture1-randomized-algorithms-intro.md · The contraction algorithm ("watermelon algorithm")
What it changes: Classifying an algorithm as LV or MC, with a one-line reason, is a natural T/F or short-answer item. See §3.1. → covered in the notes
I10direct exam signal
“It's very easy to prove, one line (it's in the homework).”
transcripts/clean/lecture1-randomized-algorithms-intro.md · Markov's inequality
What it changes: You may be asked to prove Markov's inequality. The one-line indicator proof (MU Thm 3.1) is in §3.4, with a problem. → covered in the notes
I11emphasis
“The first is very important (I put it in a box): linearity of expectation.”
transcripts/clean/lecture1-randomized-algorithms-intro.md · Linearity of expectation
What it changes: Linearity is the engine of every analysis in this unit: max-cut, MAX-SAT, rounding. The indicator-variable recipe is a reusable template (§3.3). → covered in the notes
I12emphasis
“This is a great technique. Break random variables into simple random variables—for example, Bernoulli zero-one variables.”
transcripts/clean/rand-algo-2-transcript-txt-clean.md · Linearity of expectation
What it changes: Write X = Σ indicators, then use E[indicator] = Pr[event]. Every expected-value problem here uses this exact pattern. → covered in the notes
I13warning / common mistake
“Important: the edge indicators are generally not independent. Linearity of expectation does not require independence.”
lectures-notes/Lec17_Unmarked.pdf · §2.1 (typed notes)
What it changes: A classic T/F trap. Linearity needs no independence. Independence matters only for products, e.g. the probability that a clause fails. → covered in the notes
I14student Q&A / posed question
“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?”
lectures-notes/Lec16_Unmarked.pdf · §3.4 Check for understanding
What it changes: This slide question is a template for “what does Markov give / when is it useless”. Problem 3.4. → covered in the notes

Karger's min-cut and boosting

I15emphasis
“Let that sink in: the min-cut is preserved as long as we are lucky and contract edges not in the cut.”
transcripts/clean/lecture1-randomized-algorithms-intro.md · Analysis
What it changes: The analysis was worked live on the board and recapped in the next lecture. Be able to reproduce all of it: preservation claim, degree bound, telescoping product. → covered in the notes
I16emphasis
“I call this the watermelon algorithm, for obvious reasons.”
transcripts/clean/lecture1-randomized-algorithms-intro.md · The contraction algorithm ("watermelon algorithm")
What it changes: An exam may call Karger's algorithm “the watermelon algorithm” (the typed slides do too). Same algorithm. → covered in the notes
I17direct exam signal
“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).”
transcripts/clean/rand-algo-2-transcript-txt-clean.md · The general boosting principle
What it changes: The headline principle, restated in the recap. Know it, know why (1 − p)N ≤ e−pN, and know how to pick N. Boosting slider widget in §4.3. → covered in the notes
I18warning / common mistake
“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.”
transcripts/clean/rand-algo-2-transcript-txt-clean.md · Repeating trials and keeping the smallest cut
What it changes: You can't “repeat until it outputs a min-cut”. You run N times and keep the smallest cut. This works because the cut size is checkable, while minimality isn't. → covered in the notes
I19conflict between sources
“After N independent runs, the probability that we find a minimum cut is at least 1 − (1 − p)N .”
lectures-notes/Lec17_Unmarked.pdf · §1 Claim (typed notes) vs handwritten board p.2
What it changes: The handwritten board wrote 1 − (1 − p)N+1. The typed notes and the transcript both say 1 − (1 − p)N. Use N. → covered in the notes
⚠ Board vs typed notes differ by an index. Typed notes are correct: N runs all fail with probability (1 − p)N.
I20conflict between sources
“gives P(all runs fail) ≤ (1 − p)N ≤ e−pN ≤ n−α .”
lectures-notes/Lec17_Unmarked.pdf · §1 (typed) vs board vs MU §1.5
What it changes: Three sources pick N differently: typed ⌈α·n(n−1)/2·ln n⌉ gives n−α; the board's α·n(n−1)·log n gives n−2α; MU's n(n−1)·ln n gives 1/n². All are the same calculation with different constants. §4.3 shows all three, computed by script. → covered in the notes
⚠ Not a contradiction, just different constants. Don't mix one source's N with another's exponent.

Probabilistic method and derandomization

I21direct exam signal
“I will not prove this, because it's in your homework, but here is a big takeaway of the probabilistic method.”
transcripts/clean/rand-algo-2-transcript-txt-clean.md · Expectation proves the existence of a large cut
What it changes: “If E[X] = μ then Pr[X ≥ μ] > 0 and Pr[X ≤ μ] > 0” is a homework proof. MU Lemma 6.2's contradiction proof is in §5.1. → covered in the notes
I22emphasis
“Here is the algorithmic scheme. First comes sampling.”
transcripts/clean/rand-algo-2-transcript-txt-clean.md · From existence to an algorithm
What it changes: Sampling plus boosting is the pattern: bound p = Pr[good] below by 1/poly, then repeat. The max-cut bound p ≥ 1/(m/2 + 1) is the worked instance (§5.2). → covered in the notes
I23conflict between sources
“This step in the lecture assumes m is even.”
transcripts/clean/rand-algo-2-transcript-txt-clean.md · Bounding the probability of a large cut
What it changes: The bound p ≥ 1/(m/2 + 1) needs m even. For odd m the same computation gives p ≥ 1/(m + 1). The typed slide states 1/(m/2 + 1) for all m. Both are inverse-polynomial, so the conclusion stands. → covered in the notes
⚠ Lec17 typed slide states q ≥ 1/(m/2+1) without the parity caveat. Checked by script in §5.3.
I24emphasis
“This derandomization is greedy.”
transcripts/clean/rand-algo-2-transcript-txt-clean.md · The greedy algorithm
What it changes: The method of conditional expectations reduces to a greedy rule: put each vertex opposite most of its already-placed neighbors. Know the proof chain Φ₀ ≤ Φ₁ ≤ … ≤ Φₙ. → covered in the notes
I25student Q&A / posed question
“All of you will produce a cut of size at least m/2, but it doesn't have to be the same cut.”
transcripts/clean/rand-algo-2-transcript-txt-clean.md · Lecture recap
What it changes: T/F fodder: the derandomized algorithm is deterministic for a fixed vertex order, but different orders can give different cuts. All of them have ≥ m/2 edges. → covered in the notes
I26emphasis
“you can find a small cut in a graph, but finding the largest cut can take us a long time.”
transcripts/clean/rand-algo-2-transcript-txt-clean.md · The max-cut problem
What it changes: Min-cut is in P (via flows, or Karger w.h.p.). Max-cut is NP-hard. Don't mix them up in T/F questions. → covered in the notes

Randomized rounding (MAX-SAT)

I27announcement
“There's also a problem in the homework where you apply the same techniques to yet another problem.”
transcripts/clean/rand-algo-2-transcript-txt-clean.md · Homework and the next lecture
What it changes: Expect randomized rounding on a new problem. Practice the recipe (ILP → relax → round with probability = LP value → per-constraint bound) on unseen problems (§6.4). → covered in the notes
I28warning / common mistake
“The 7/8 result here is a guarantee for exactly three distinct literals per clause.”
lectures-notes/CS6515__Grad_Algorithms_18.pdf · §4 Important distinction
What it changes: Trap: 7/8 holds for MAX-E3SAT (exactly 3 literals). With clauses of size 1 or 2 allowed, fair coins only guarantee 1/2. This is a slide exercise. → covered in the notes
I29emphasis
“Håstad proved it's NP-hard to do better than 7/8.”
transcripts/clean/LP4_Max-SAT_Transcripts_01-24-clean.md · 8. Exact-k-SAT
What it changes: Fact for T/F: fair coins are already optimal for MAX-E3SAT unless P = NP. → covered in the notes
I30conflict between sources
“taking the better bound separately for each clause does not by itself justify taking the better of two whole assignments.”
transcripts/clean/LP4_Max-SAT_Transcripts_01-24-clean.md · 24. Best of Two
What it changes: The video waves its hands on the 3/4 proof. The correct argument averages: E[max] ≥ ½(E[M₁] + E[M₂]) and ak + βk ≥ 3/2. §6.5 writes it out, with the inequality checked by script. → covered in the notes
⚠ The video's “clause by clause, take the better one” is not a valid proof. Use the averaging argument.
I31warning / common mistake
“The guarantee is in expectation; an individual run need not attain the bound.”
lectures-notes/CS6515__Grad_Algorithms_18.pdf · §3 Algorithmic accounting
What it changes: Always say “in expectation”. One run of fair-coin MAX-SAT can satisfy fewer than m/2 clauses. → covered in the notes

P, NP, and reductions

I32direct exam signal
“(Maybe I'll ask this on the exam; I'm telling you before the other section.)”
transcripts/clean/lecture2-np-reductions-sat.md · SAT and its variants
What it changes: Strongest direct signal. “Why is Max-SAT hard?” Reduce SAT → Max-SAT with the same formula: satisfiable ⇔ the max is m. Full answer in §10.2, problem 10.1. → covered in the notes
I33direct exam signal
“So it's not symmetric at all; that's a great multiple-choice question to think about.”
transcripts/clean/lecture2-np-reductions-sat.md · Student questions on NP-hardness
What it changes: Reduction direction will be tested. A → B says B is at least as hard as A. It says nothing about B → A. Drilled in §9.4 and §9.5. → covered in the notes
I34student Q&A / posed question
“A: No, no. They very much depend on A and B.”
transcripts/clean/lecture2-np-reductions-sat.md · Student questions on NP-hardness
What it changes: f and g are specific to the pair (A, B). There's no universal translator. → covered in the notes
I35student Q&A / posed question
“No, there's no other restriction, as long as you satisfy this if-and-only-if.”
transcripts/clean/lecture2-np-reductions-sat.md · Reductions
What it changes: f need not be injective or onto. The only requirements: solvable ⇔ solvable, g recovers a solution, and f and g run in polynomial time. → covered in the notes
I36warning / common mistake
“f must be connected to g in a very specific way: I need to be able to recover the solution at the end.”
transcripts/clean/lecture2-np-reductions-sat.md · Reductions
What it changes: The “silly reduction” (map everything to K2026) fails because g can't recover anything. Recovery is part of the course's definition. → covered in the notes
I37warning / common mistake
“So knapsack, as we saw it in class, is not a search problem.”
transcripts/clean/lecture2-np-reductions-sat.md · Search problems vs. decision problems
What it changes: Class-specific definition: NP = search problems with a poly-time verifier. Optimization knapsack isn't in NP under it. Textbooks (KT) put decision knapsack / Subset Sum in NP. Answer with the class definition. → covered in the notes
⚠ Conflicts with textbook framing (KT §8.8: Subset Sum is NP-complete, as a decision problem). Not a contradiction: different problem versions.
I38warning / common mistake
“Important: they don't have to be search problems; they can be crazy problems, as long as everybody reduces to them.”
transcripts/clean/lecture2-np-reductions-sat.md · The picture: P, NP, NP-hard, NP-complete
What it changes: NP-hard does not imply in NP. Max-SAT and ILP (optimization versions) are NP-hard but not in NP under the class definition. NP-complete = NP ∩ NP-hard. → covered in the notes
I39student Q&A / posed question
“A: We don't know yet how to solve them in polynomial time.”
transcripts/clean/lecture2-np-reductions-sat.md · Student questions on NP-hardness
What it changes: Never write “NP-hard problems cannot be solved in polynomial time”. Write “no poly-time algorithm is known; one would imply P = NP”. → covered in the notes
I40emphasis
“Two conclusions to make explicit in your notes.”
transcripts/clean/lecture3-np-complete-graph-problems.md · What does a reduction preserve? (summary)
What it changes: Make these explicit: A → B with A NP-hard ⇒ B NP-hard; B ∈ P ⇒ A ∈ P; both together ⇒ P = NP. Table and drills in §9.5. → covered in the notes
I41student Q&A / posed question
“the reduction in the other direction doesn't have to be the inverse operation.”
transcripts/clean/lecture3-np-complete-graph-problems.md · Q&A: what about the other direction?
What it changes: IS → SAT exists (IS ∈ NP, Cook–Levin), but it isn't 3SAT → IS run backwards. → covered in the notes
I42emphasis
“I don't expect you to have an illumination during the exam or homework.”
transcripts/clean/lecture2-np-reductions-sat.md · Why reductions matter (intuition)
What it changes: Exam reductions should be close to known ones (IS/VC/Clique complements, 3SAT gadgets, SAT → variant). Memorize the lecture reductions and the decision guide (§12.2). → covered in the notes

SAT, 2-SAT, 3-SAT

I43emphasis
“all literals in the same strongly connected component must get the same truth value.”
transcripts/clean/lecture2-np-reductions-sat.md · 2SAT is in P
What it changes: Know the implication graph ((a ∨ b) ≡ (ā → b) ∧ (b̄ → a)), the SCC observation, and the unsatisfiability test. 2-SAT SCC widget in §10.3. → covered in the notes
I44answer expectations
“you have to follow a certain order in the assignment (watch the video; it's not that important for this class)”
transcripts/clean/lecture2-np-reductions-sat.md · 2SAT is in P
What it changes: Lower priority in lecture, but the GR2 video (now in extra-transcripts) gives the full rule: repeatedly set a sink SCC true and its complement (a source SCC) false. §10.3. → covered in the notes
⚠ Assignment order comes from the GR2 video (extra transcript), not from lecture.
I45answer expectations
“But note that for a valid reduction we need the if-and-only-if: we have to check both directions.”
transcripts/clean/lecture2-np-reductions-sat.md · 3SAT is NP-hard
What it changes: Every reduction answer must prove both directions. One-directional proofs lose points. → covered in the notes
I46student Q&A / posed question
“Why not 2SAT? I need this intermediate structure”
transcripts/clean/lecture2-np-reductions-sat.md · 3SAT is NP-hard
What it changes: Be able to explain why clause-splitting needs three slots (two connectors plus one original literal). That's why 2-SAT stays in P. → covered in the notes

Graph reductions

I47answer expectations
“1. Input transformation: transform an input of the first problem into an input of the second, in polynomial time.”
transcripts/clean/lecture3-np-complete-graph-problems.md · Independent set is NP-hard (3SAT → Independent Set)
What it changes: His reduction format has three steps: input transformation, correctness (⇔), solution recovery. The template in §12.1 merges this with “show it is in NP”. → covered in the notes
I48answer expectations
“Those two sentences are enough: linear in this, quadratic in that, therefore polynomial. Done.”
transcripts/clean/lecture3-np-complete-graph-problems.md · Step 1: input transformation
What it changes: For polynomial time, two sentences of counting (vertices, edges) are enough. Don't over-write. → covered in the notes
I49answer expectations
“we don't need super detailed proofs as long as we have the right ideas.”
transcripts/clean/lecture3-np-complete-graph-problems.md · Step 2: the if-and-only-if
What it changes: Detail level: clear ideas in both directions beat formalism. Matches the Unit 1 solutions, which use short prose proofs. → covered in the notes
I50student Q&A / posed question
“every time you see a variable and its negation, add an edge”
transcripts/clean/lecture3-np-complete-graph-problems.md · Step 1: input transformation
What it changes: The two edge types of 3SAT → IS: clause cliques (exactly one literal per clause) and complement edges (no contradictions). k = m. The gadget builder widget is in §11.1. → covered in the notes
I51answer expectations
“For example, the contrapositive: instead of "if P then Q", prove "if not Q then not P".”
transcripts/clean/lecture3-np-complete-graph-problems.md · Step 2: the if-and-only-if
What it changes: The ⇐ direction may be easier as a contrapositive. Allowed and encouraged. → covered in the notes
I52direct exam signal
“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”
transcripts/clean/lecture3-np-complete-graph-problems.md · Vertex cover
What it changes: Flagged for the final, but S independent ⇔ V∖S vertex cover is core Exam 3 material too (IS → VC). Proof in §11.3. → covered in the notes
⚠ Explicitly about the final.
I53student Q&A / posed question
“Q: Is it always true that the complement of a vertex cover is an independent set?”
transcripts/clean/lecture3-np-complete-graph-problems.md · Vertex cover
What it changes: Yes, both directions. KT (8.3) gives the two-line proof, reproduced in §11.3. → covered in the notes
I54emphasis
“do reductions preserve approximation factors?”
transcripts/clean/lecture3-np-complete-graph-problems.md · Do reductions preserve approximation?
What it changes: No. A 2-approximation for VC gives nothing for IS (star / perfect-matching example). This is a likely T/F item. §11.4. → covered in the notes
I55emphasis
“if you reduce to a problem in P, your problem is in P.”
transcripts/clean/lecture3-np-complete-graph-problems.md · Reductions preserve "easy" too: bipartite matching → max flow
What it changes: Reductions also prove easiness: bipartite matching → max flow, with the conservation-of-flow proof that saturated middle edges form a matching (§11.5). → covered in the notes
I56student Q&A / posed question
“if A is NP-hard and B is in P, then?”
transcripts/clean/lecture3-np-complete-graph-problems.md · What does a reduction preserve? (summary)
What it changes: Answer: then P = NP. The canonical “dramatic” question. Problem 9.5. → covered in the notes
I57student Q&A / posed question
“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?”
transcripts/clean/lecture3-np-complete-graph-problems.md · Decision vs. search versions (self-reducibility)
What it changes: Low priority (“for your own entertainment”). The idea (search via decision + self-reducibility) is sketched in §9.6, from KT's binary-search remark. → covered in the notes

OMS videos NP1/NP2/GR2 (extra)

I70warning / common mistake
“Often they'll show the reduction in the other direction. That's not really proving anything.”
extra-transcripts/NP1_Definitions_Transcripts.txt · 26. Simpler Proof Approach
What it changes: The video names the classic lost-points error that the professor also flagged (I33): reducing the new problem to the known one. Always reduce FROM the known NP-complete problem. → covered in the notes
I71answer expectations
“normally, it's just going to take one or two sentences to show that a particular problem is in NP”
extra-transcripts/NP1_Definitions_Transcripts.txt · 8. SAT in NP (Answer)
What it changes: “In NP” takes one or two sentences: name the certificate (the proposed solution) and the poly-time check. Matches the professor's “two sentences” for polynomial time (I48). Verifier table in §9.2. → covered in the notes
I72student Q&A / posed question
“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.”
extra-transcripts/NP1_Definitions_Transcripts.txt · 15. Solution: Knapsack Complexity
What it changes: Agrees with the professor (I37) and adds the fix: Knapsack-search (add a goal g, ask for value ≥ g) is in NP, and binary search on g recovers the optimum. §9.2 and problem 9.10. → covered in the notes
I73student Q&A / posed question
“The MST problem is in the class NP, and the MST problem is in the class P.”
extra-transcripts/NP1_Definitions_Transcripts.txt · 10. MST (Answer)
What it changes: Optimization problems can be in NP when optimality is checkable in poly time (run Kruskal/Prim and compare weights). That is why MST is in NP but knapsack (pseudo-poly DP) is not known to be. §9.2. → covered in the notes
I74warning / common mistake
“the important thing to remember is that NP does not stand for not polynomial time”
extra-transcripts/NP1_Definitions_Transcripts.txt · 18. NP acronym for?
What it changes: NP = nondeterministic polynomial time. A classic T/F trap. §9.2. → covered in the notes
I75emphasis
“we might create n new variables for each clause, so it has order nm variables in the worst-case”
extra-transcripts/NP2_3SAT_Transcripts.txt · 15. Satisfying Assignment
What it changes: The size bound for SAT → 3-SAT: O(nm) variables and clauses, which is polynomial. Use it in the “poly time” sentence. §10.4. → covered in the notes
I76announcement
“In problem 8.8, you consider exact 4-SAT.”
extra-transcripts/NP2_3SAT_Transcripts.txt · 16. Practice Problems
What it changes: Suggested practice: exact 4-SAT is NP-complete. Solved in problem 10.10 with a padding gadget, brute-force verified. → covered in the notes
I77emphasis
“if a set of vertices S is a sink SCC, then its compliment is a source SCC and vice versa”
extra-transcripts/GR2_2-Satisfiability_Transcripts.txt · 11. 2SAT Algorithm
What it changes: The key fact behind the 2-SAT assignment rule (the professor deferred it to this video, I44). The full algorithm and proof are now in §10.3. → covered in the notes
I78emphasis
“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”
extra-transcripts/GR2_2-Satisfiability_Transcripts.txt · 5. Simplifying Input
What it changes: Step 0 of the 2-SAT algorithm: eliminate unit clauses by forcing their literal. §10.3, problem 10.11. → covered in the notes

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).

TopicLecture / videoSlides / boardTextbookHW5 (actual)WeightNotes §
Las Vegas vs Monte CarloOct 29Lec 16 typed §2, board p1MU 1.x intro—M3.1
Bernoulli / binomial / geometric, expectationOct 29Lec 16 §3, board p1–2MU 2.1, 2.2, 2.4—M3.2
Linearity of expectation, indicator methodOct 29, Nov 3, LP4Lec 16 §3.3, Lec 17 §2.1MU 2.1.1used everywhereH3.3
Markov's inequality (+ proof)Oct 29Lec 16 §3.4, board p3MU 3.1proof is HWM3.4
Karger's contraction (watermelon) + analysisOct 29, Nov 3 recapLec 16 §4, board p3–5MU 1.5#19: count min cuts, α-small cutsH4.1–4.2
Boosting: 1 − (1 − p)N, choosing NNov 3Lec 17 §1, board p1–3MU 1.5 end#21(d), #22(b–c)H4.3
Probabilistic method: E[X] = μ ⇒ both sides possibleNov 3Lec 17 §2, board p3–4MU 6.2 (Lemma 6.2)#20(b)M5.1
Max-cut ≥ m/2, Pr[X ≥ m/2] ≥ 1/(m/2+1)Nov 3Lec 17 §2.1–2.2, board p4–5MU 6.2.1likelyH5.1–5.2
Derandomization (conditional expectations)Nov 3, LP4 §7Lec 17 §3, board p5–8MU 6.3likelyM–H5.3
HW5-only techniques: early-stopped contraction, rounding + repetition, challenge protocols (zero knowledge)— (HW5)——#19.2, #21(d–e), #22H15
Union bound / Ramsey coloring; sample & modify— (not in lecture)—MU 6.1, 6.4—L5.4
MAX-SAT fair coins ½, MAX-E3SAT 7/8LP4 §4–8Lec 18 §2, §4MU 6.2.2#20(a),(c)H6.1–6.2
ILP, LP relaxation, randomized rounding 1 − 1/eLP4 §9–22Lec 18 §1, §3—#21: hitting set + repetitionH6.3–6.4
Best of two: ¾LP4 §23–24———M6.5
Bounds on OPT from a solution, a guarantee, an LP value (Q1(f) type)(both real exams)———H6.6
P, NP (search problems), NP-hard, NP-complete; “in NP” proofs; MST, knapsack, knapsack-searchNov 10 (+ NP1 video)board p1–3KT 8.3–8.4—H9.1–9.2
Reductions (f, g, ⇔), direction, transitivityNov 10 (+ NP1 video)board p2KT 8.1HW6H9.3–9.4
What reductions preserve (hard →, easy ←, P = NP)Nov 12—KT (8.1)–(8.2)—H9.5
SAT, Cook–Levin (statement), Max-SAT is hard, ILP is hardNov 10, LP4 §10board p3KT 8.4—H10.1–10.2
2-SAT ∈ P (implication graph, SCCs)Nov 10 (+ GR2 video)board p3–4——M10.3
3-SAT NP-hard (clause splitting); exact-4-SAT, stingy SATNov 10 (+ NP2 video)board p4–5KT 8.4 (circuit route), DPV 8.3, 8.8 (named in NP2)HW6H10.4
3-SAT → Independent SetNov 12(board missing)KT 8.2HW6H11.1
IS ↔ Clique, IS ↔ Vertex CoverNov 12(board missing)KT 8.1HW6H11.2–11.3
Approximation is not preservedNov 12———M11.4
Bipartite matching → max flow (easiness)Nov 12—KT (8.1) remark—M11.5
Decision vs search, self-reducibilityNov 12 (“for your own entertainment”)—KT 8.1—L9.6
Set Cover / Set Packing / Circuit-SAT——KT 8.1, 8.4—L11.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 partPointsTypeWhere it came from
Q1(a)(c) LP duality / Farkas5 + 6select-ALL multiple choicelecture theorems (weak/strong duality, Farkas); the false options needed a counterexample
Q1(b) complementary slackness5select-onelecture theorem
Q1(d) one projected gradient step10calculation on a given instancelecture algorithm, by hand
Q1(e) first-order optimality63-line prooflecture fact
Q1(f) bounds on OPT from a 2-approximation + a matching8“strongest bounds”, with a distractorlecture guarantees; the matching info was useless (the trap)
Q2 greedy independent set (valid, Δ-approximation, tight family)15guided proof + constructsame genre as HW4 #17 (greedy load balancing), new problem; tight family = star
Q3 gradient-descent chain (3 hinted parts)20guided proofHW4 #16 re-skinned; the hint says “(This was a homework problem!)”
Q4 set cover: ILP, threshold rounding at 1/k, k-approximation, tight instance25 (30 in the body)guided proof + constructHW4 #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.

Predicted Exam 3 blueprint (my inference, used for Mocks A and B) Q1 (40): select-all on LV/MC, Karger, linearity/indicators, MAX-SAT guarantees, P/NP and reduction direction; one calculation (boosting N, a 3-SAT → IS graph, or a 2-SAT SCC run); one short proof (Markov, E[X] = μ, or Max-SAT is NP-hard); one bounds question (e.g. expectation ≤ OPT ≤ LP*). Long questions: re-skins of HW5. Most likely #21 with roles swapped (set cover randomized rounding + repetition, the exact move Exam 2 made with HW4 #18), #19 (min-cut counting / early stop), #20 (exact-k-SAT + probabilistic method + tight example) or #22 (repetition protocol). Plus one reduction (HW6 / lecture style). Every long question will probably end with a 2–5 point “construct an instance”.
Difficulty calibration Exam 2's proofs were 4–12 lines and every non-trivial step was hinted. The constructions were tiny (a star; U = S₁ = S₂ = S₃). The trap questions tested exact statements (“every constraint is tight”, “the matching gives an upper bound of 16”). So the knob is “a lecture or homework argument on a slightly changed object, with hints”, not new ideas. The §15 re-skins and both mocks are written at that level. Problems tagged “challenge” are a notch above it.

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:

PartPointsTypeReused from
§1 short answer (7 × 5)35T/F or one-line fact + 1–2 line justificationLecture 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)20Run a lecture algorithm on a given exampleLecture example type (Ford–Fulkerson by hand)
§3.1–3.2 inversion counting (MergeAndCount + recursion)15Design + describeClassic textbook / lecture problem
§3.3 prove T(n) = O(n log n) by induction10Reproduce a lecture proofThe official solution says only “See handwritten notes from Lec 2”
§4 knapsack DP (table, recurrence + correctness, runtime + pseudo-poly)20Design + correctness + runtime analysisThe 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.

What the Unit 1 practice exam suggested (still consistent with §2.2) Be able to reproduce, from a blank page: the Karger bound (4.2), boosting with an explicit N (4.4), E[cut] = m/2 and Pr[X ≥ m/2] ≥ 1/(m/2+1) (5.2–5.3), the derandomization lemma (5.4), the rounding lemma (6.8), the ¾ argument (6.7), SAT → Max-SAT (10.1), clause splitting (10.6), 3-SAT → IS (11.2), and IS ↔ VC ↔ Clique (11.3–11.4). Short answers will test definitions and directions (§9.5, §7). The transcripts agree: “I don't expect you to have an illumination” ⚑ Flagged in lecture · I42. Proofs don't need to be “super detailed as long as we have the right ideas” ⚑ Flagged in lecture · I49.

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.”

After this section you can
  • 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.”

Las VegasMonte Carloanswer: always correct ✓running time: random variablewe analyze: E[running time]e.g. randomized Quicksort(worst n², average about n log n)answer: correct w.p. ≥ p (may be wrong)running time: boundedwe analyze: Pr[success] = pe.g. Karger's contraction, Fermat test,fair-coin MAX-SAT
Which quantity is random: the time (Las Vegas) or the correctness (Monte Carlo)?
How to read this figure Two columns, one per paradigm. Each row asks the same question: is the answer guaranteed, is the time guaranteed, what do we compute? The answer to “which is random?” is opposite in the two columns.
Worked example: converting Monte Carlo to Las Vegas. Sampling a random cut and outputting it is Monte Carlo for “find a cut with ≥ m/2 edges”. But we can check the property in polynomial time (count crossing edges). So “repeat until the check passes” never outputs a wrong answer. Its number of rounds is geometric with mean 1/p ≤ m/2 + 1 (MU §6.2.1). Now the randomness is in the time: Las Vegas. For min-cut we can't check minimality, which is why Karger stays Monte Carlo (§4.3).
Traps
  • “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”.
✍ 3.1Las Vegas or Monte Carlo? short answer ⚑ Flagged in lecture · I09
Source: Lecture question (Oct 29: “Las Vegas or Monte Carlo?”) + slide examples
Classify each algorithm as Las Vegas or Monte Carlo and justify in one line.
  1. Randomized Quicksort (random pivots).
  2. Fermat's test: pick random a, answer “prime” iff ap−1 ≡ 1 (mod p).
  3. Karger's contraction algorithm (one run).
  4. Repeat “random cut; if it has ≥ m/2 edges, output it” until it outputs.
  5. Fair-coin assignment for MAX-SAT, output whatever you get.
Show solution
  1. Las Vegas. Every pivot sequence sorts correctly; only the number of comparisons is random (average O(n log n), worst n²).
  2. Monte Carlo with one-sided error: a prime is always classified correctly, but a composite can pass (remainder 1) and be wrongly called prime.
  3. 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)).
  4. 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.
  5. 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.

Bernoulli(0.3)01Binomial(8, 0.3)012345678Geometric(0.3)123456789one trial# successes in 8 trials# trials until 1st success
Same coin (p = 0.3), three stories. Bar heights are exact probabilities, computed in figs.py.
How to read this figure One coin with p = 0.3, three random variables. Left: a single trial. Middle: how many of 8 trials succeed (peak near np = 2.4). Right: which trial is the first success (always decreasing, factor 0.7 per step). The y-scale is shared, so heights compare directly.
Worked example. p = 1/4. Number of successes in 4 trials: Pr[X = 2] = 6·(1/16)·(9/16) = 27/128. Trials until the first success: Pr[Y = 3] = (3/4)²·(1/4) = 9/64 and E[Y] = 4. “Run Karger until it succeeds” is geometric with p = 2/(n(n−1)), so it takes n(n−1)/2 runs on average.
Traps The geometric range starts at 1, not 0. Its formula has p once and (1 − p) to the power k − 1. Binomial counts successes; geometric counts trials.
Textbook only (MU §2.1, §2.4) Independence of random variables: X, Y are independent iff Pr[(X = x) ∩ (Y = y)] = Pr[X = x]·Pr[Y = y] for all x, y (MU Def 2.2). Expectations can be infinite: X = 2i with probability 2−i has E[X] = Σ 1 = ∞. Geometric facts: memoryless, Pr[X = n + k | X > k] = Pr[X = n], so past failures don't matter. Tail sum: for X ∈ {0, 1, 2, …}, E[X] = Σi≥1 Pr[X ≥ i], which gives E[Geo(p)] = Σ(1−p)i−1 = 1/p. Coupon collector (MU §2.4.1): collecting all n types takes Σ n/(n−i+1) = n·H(n) ≈ n ln n boxes in expectation (n = 10: ≈ 29.29). It is a sum of geometrics, then linearity.
✍ 3.2Bernoulli, binomial, geometric by hand calc
Source: Lecture definitions (Oct 29) + MU §2.2, §2.4
A trial succeeds with probability p = 1/4, independently.
  1. X = number of successes in 4 trials. Compute Pr[X = 2], Pr[X = 0], and E[X].
  2. Y = number of trials until the first success. Compute Pr[Y = 3], Pr[Y > 3], and E[Y].
  3. Which of X, Y describes “run Karger until the first success”?
Show solution
  1. 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).
  2. 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).
  3. Y, the geometric one: “repeat until success”. This is exactly why Pr[success within N runs] = Pr[Y ≤ N] = 1 − (1 − p)N.
✍ 3.9Memoryless + coupon collector (textbook only) textbookcalc
Source: MU §2.4, Lemma 2.8–2.9, MU §2.4.1 (assigned reading; not covered in lecture)
  1. For X ~ Geo(p), show Pr[X = n + k | X > k] = Pr[X = n] (memoryless).
  2. 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
  1. 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.
  2. 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.

Worked example (Lec 16 quick example). n fair coin tosses, X = number of heads = Σ Xᵢ. E[Xᵢ] = ½, so E[X] = n/2, with no 2ⁿ enumeration. The same three steps give E[random cut] = m/2 (§5.2) and E[#satisfied clauses] = Σ(1 − 2−kⱼ) (§6.1).
Traps
  • 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).
Textbook only (MU §2.1.1–2.1.2) E[cX] = c·E[X] (Lemma 2.2). Jensen: for convex f, E[f(X)] ≥ f(E[X]). In particular E[X²] ≥ (E[X])², because E[X²] − (E[X])² = E[(X − E[X])²] ≥ 0. MU's example: side X uniform on {1, …, 99} gives E[X²] = 9950/3 ≈ 3316.67, not 50² = 2500. Linearity covers sums and constant multiples, not squares or products.
✍ 3.3Expected number of heads, and the binomial mean proof ⚑ Flagged in lecture · I11 I12
Source: Lec 16 typed notes, “Quick example” (slide exercise)
Toss a fair coin n times and let X count heads. Without enumerating the 2n outcomes, find E[X]. Then generalize to get the expectation of a Binomial(n, p) random variable.
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.

✍ 3.8Jensen's inequality (textbook only) textbookcalc
Source: MU §2.1.2 (assigned reading; not covered in lecture)
A square's side X is chosen uniformly from {1, 2, …, 99}. Compare E[X²] with (E[X])², and state Jensen's inequality.
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. ∎

012345678910E[X] = 3a = 6true Pr[X ≥ 6]= 0.0473Markov boundE[X]/a = 0.5
X ~ Binomial(10, 0.3). Markov only uses E[X] and X ≥ 0, so its bound (0.5) is far above the true tail (red bars).
How to read this figure The bars are the exact distribution of X ~ Bin(10, 0.3). The red bars are the event X ≥ 6, whose true probability is printed on the right. Markov's bound 3/6 = 0.5 is much larger. Markov is valid but loose. It ignores the shape of the distribution.
Worked example (lecture). Quicksort with E[X] ≈ n log n comparisons: Pr[X ≥ 10 n log n] ≤ (n log n)/(10 n log n) = 1/10. Slide check: E[X] = 6 gives Pr[X ≥ 24] ≤ 1/4, but for a = 4 the bound is 3/2 > 1: useless. MU's coin example: n fair flips, Pr[≥ 3n/4 heads] ≤ (n/2)/(3n/4) = 2/3.
Traps X must be non-negative. The bound is useless for a ≤ E[X]. Markov gives a bound on a probability, never an exact value (“the language matters”).
✍ 3.4What Markov does and doesn't tell you calcshort answer ⚑ Flagged in lecture · I14
Source: Lec 16 typed notes, “Check for understanding” (verbatim)
Suppose E[X] = 6 and X ≥ 0. What does Markov say about P(X ≥ 24)? Can it tell us P(X ≥ 4) is small?
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.

✍ 3.5Prove Markov's inequality proof ⚑ Flagged in lecture · I10
Source: Lecture: “It's very easy to prove, one line (it's in the homework)”. Proof from MU Thm 3.1
Let X ≥ 0 be a random variable and a > 0. Prove Pr[X ≥ a] ≤ E[X]/a.
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.

✍ 3.6Quicksort and Markov calc
Source: Lecture example (Oct 29) + variant
Let X be the number of comparisons of randomized Quicksort on n items.
  1. If E[X] = n log n, bound Pr[X ≥ 10 n log n].
  2. If instead E[X] = 2 n ln n, bound Pr[X ≥ 10 n ln n].
  3. Does (a) say that Quicksort is O(n log n) in the worst case?
Show solution
  1. Markov: ≤ (n log n)/(10 n log n) = 1/10.
  2. ≤ (2 n ln n)/(10 n ln n) = 1/5.
  3. 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.”

start6/8 good2/8 bad (Δ edge)5/7 good2/7 bad✗✗both good:6/8 · 5/7 = 15/28multiply along the good path; each factor is conditional on the past being good
Chain rule as a tree: the second factor (5/7) is computed in the world where the first draw was good.
How to read this figure Read left to right. Each branch is labeled with its probability given everything to its left. Only the all-green path counts, and its probability is the product of its labels: the chain rule.
Worked example. Draw 2 edges without replacement from 8 edges, 2 of which are “bad”. Pr[both good] = Pr[1st good]·Pr[2nd good | 1st good] = (6/8)·(5/7) = 15/28. This is exactly the shape of Karger's product.
Trap Don't multiply unconditional probabilities as if the steps were independent. They aren't: each contraction changes the graph.
Four rules used in every proof of this unit
  1. Complement: Pr[not A] = 1 − Pr[A]. (“Success” = 1 − Pr[all runs fail].)
  2. Independent events multiply: Pr[A ∩ B] = Pr[A]·Pr[B]. (N independent runs all fail: (1 − p)N; all k literals false: ∏(1 − pᵣ).)
  3. Disjoint events add: Pr[A₁ ∪ ⋯ ∪ At] = Σ Pr[Aᵢ] ≤ 1. (Counting min cuts, §15.1: one run returns one cut.)
  4. 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.
And 1 − x ≤ e−x for every real x, which turns (1 − p)N into e−pN. Also the tail-sum formula for a count T ≥ 0: E[T] = Σt≥0 Pr[T > t] (same as Σi≥1 Pr[T ≥ i]).
✍ 3.7True/False: probability tools T/F ⚑ Flagged in lecture · I13
Source: Exam-style (Unit 1 short-answer format), built from Lec 16/17 typed notes
  1. Linearity of expectation E[X + Y] = E[X] + E[Y] requires X and Y to be independent.
  2. Markov's inequality applies to every random variable with finite expectation.
  3. For a 0/1 random variable I, E[I] = Pr[I = 1].
  4. The probabilities in randomized-algorithm guarantees are taken over a random input distribution.
  5. A Monte Carlo algorithm has a bounded running time but may output a wrong answer.
  6. 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
  1. 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.
  2. False. It needs X ≥ 0. Counterexample: X = −1 or +1 with probability ½ each, a = 1: Pr[X ≥ 1] = ½, but E[X]/a = 0.
  3. True. E[I] = 1·Pr[I=1] + 0·Pr[I=0]. This is the step behind every “E[Xₑ] = Pr[e crosses]”.
  4. 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.
  5. True. Definition on the Lec 16 typed notes (Karger is the example).
  6. True. MU Lemma 2.9: E[X] = Σᵢ Pr[X ≥ i] = Σᵢ (1−p)i−1 = 1/p.
Recall check (answer aloud, then open)
Linearity of expectation: does it need independence?
No. Independence is only needed for products, e.g. Pr[all literals false].
Markov: hypotheses and statement?
X ≥ 0 and a > 0 ⇒ Pr[X ≥ a] ≤ E[X]/a.
E[Geo(p)] and its story?
1/p: the expected number of trials until the first success.
Why is Karger Monte Carlo and Quicksort Las Vegas?
Karger's time is fixed but its answer may be wrong; Quicksort's answer is always right but its time is random.

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.

After this section you can
  • 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
abcdcontract {a,b}5 edges, 4 verticesmerge a,babcdparalleledges kept4 edges (a-b gone), 3 vertices
Contracting {a,b}: the edge a–b disappears (it would be a self-loop). a–d and b–d both become ab–d: keep both copies.
How to read this figure Left: before. The red edge a–b is picked. Right: a and b are one supervertex “ab”. The edge a–b itself is gone (it would be a self-loop). Both a–d and b–d now run from ab to d, so there are 2 parallel (green) edges. The vertex count drops by exactly 1 per contraction, so there are always n − 2 contractions.
Worked example. In the §4.2 graph (two triangles {1,2,3}, {4,5,6} plus bridges 3–4, 2–5), contract 1–2: the supervertex {1,2} keeps edges to 3 (two parallel copies: 1–3 and 2–3) and to 5 (via 2–5). Now 5 vertices and 7 edges remain. Contract 4–6, then 5–{4,6}: the right triangle is one blob with two edges to the left side. Contract 3–{1,2}: two blobs remain, joined by 3–4 and 2–5. That's Δ, a min cut. Had the first pick been 3–4 (probability 2/8 of hitting Δ), Δ could never be returned.
Traps Keep parallel edges (they are real edges of the original cut, and they change the sampling probabilities). Delete self-loops. “Uniform” means over current edges with multiplicity, not over vertex pairs. It is Monte Carlo: it always outputs a cut, but contracting a min-cut edge early destroys that cut.

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. ∎

00.518/10k=17/9k=26/8k=35/7k=44/6k=53/5k=62/4k=71/3k=81/45blue: bound on Pr[k-th contraction avoids Δ | so far so good] · red: running product
n = 10: early contractions are almost surely safe; the last ones are the risky ones. The product telescopes to 2/(n(n−1)) = 1/45.
How to read this figure For n = 10, each blue bar is the bound on “step k avoids Δ, given that all previous steps did”. It starts at 8/10 and falls to 1/3. The red line multiplies the bars as you go and ends at 1/45 = 2/(10·9). Almost all the risk is in the last few contractions.
123456Δ = {3–4, 2–5}n = 6, m = 8min-cut size λ = 23 min cuts:{1}|rest, {6}|rest,{1,2,3}|{4,5,6}
Worked-example graph: two triangles joined by two bridges (red). Vertices 1 and 6 have degree 2, so cutting them off is also a min cut.
How to read this figure The worked-example graph. Red edges are the min cut Δ we track. The dashed line shows its two sides. Vertices 1 and 6 have degree 2, so “1 alone” and “6 alone” are also min cuts. Three min cuts in total.
Worked example (graph above, n = 6, m = 8, |Δ| = 2). First step: Pr[avoid Δ] = 6/8 = 3/4 ≥ 1 − 2/6 = 2/3 (the bound is worst case). Degrees: deg(1)=2, deg(2)=3, deg(3)=3, deg(4)=3, deg(5)=3, deg(6)=2, all ≥ |Δ| = 2. Theorem: Pr[return Δ] ≥ 2/(6·5) = 1/15 ≈ 0.0667. Enumerating every possible run (calc.py) gives the exact value 6/35 ≈ 0.1714, and Pr[return some min cut] = 19/35 ≈ 0.5429. For the cycle C₅ the bound is exact: each of its 10 min cuts comes out with probability exactly 1/10.
▶ Widget: Karger's contraction, step by step
Or click an edge to contract it yourself. Red edges are the fixed min cut Δ = {3–4, 2–5}. Numbers on edges count parallel copies.
Traps
  • 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.
✍ 4.1Karger on the worked-example graph calc ⚑ Flagged in lecture · I15
Source: Lecture analysis (Oct 29) applied to the §4.2 graph
Use the graph in §4.2 (two triangles {1,2,3}, {4,5,6} joined by bridges 3–4 and 2–5; n = 6, m = 8) and the fixed min cut Δ = {3–4, 2–5}.
  1. What is the probability that the first contraction avoids Δ? Compare it with the bound 1 − 2/n used in the proof.
  2. Check the degree bound deg(v) ≥ |Δ| for every vertex.
  3. State the theorem's lower bound on Pr[return Δ]. The exact value (computed by enumerating all runs) is 6/35. Is that consistent?
  4. Why is Pr[return some min cut] (19/35) larger?
Show solution
  1. (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).
  2. 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.)
  3. 2/(n(n−1)) = 2/30 = 1/15 ≈ 0.0667. The exact 6/35 ≈ 0.1714 is above it. Consistent.
  4. 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 Δ.
✍ 4.2Reproduce the Karger bound (full proof) proofexam-style ⚑ Flagged in lecture · I15
Source: Lecture derivation (Oct 29 board + Lec 16 typed notes): be able to write it from memory
Let G be a connected multigraph on n vertices and Δ a fixed minimum cut. Prove that one run of the contraction algorithm returns Δ with probability at least 2/(n(n−1)).
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)). ∎

✍ 4.3Why keep parallel edges? short answer
Source: Lec 16 typed notes (“parallel edges must be retained”) + MU §1.5
In the contraction step we delete self-loops but keep parallel edges. Give two reasons the analysis needs the parallel edges.
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.

✍ 4.9The cycle shows the bound is tight calcchallenge
Source: Derived example (computed by full enumeration in calc.py); the corollary is a derivation, not stated in lecture
Let G = C₅ (cycle on 5 vertices). Every pair of edges is a min cut (size 2).
  1. How many min cuts does C₅ have? Compare Pr[return a fixed one] with 2/(n(n−1)).
  2. Using only the theorem, show that every graph has at most n(n−1)/2 minimum cuts.
Show solution
  1. 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.
  2. 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.

00.250.50.751050100150200250300N = 1/p = 45N = 205: ≥ 0.99N = number of independent runs (keep the smallest cut)solid: 1 − (1 − p)^Ndashed: 1 − e^(−pN) (lower bound)
Boosting Karger on n = 10 vertices (p = 1/45). After 1/p runs you are at about 1 − 1/e; a few more multiples of 1/p push failure toward 0.
How to read this figure n = 10, p = 1/45. The solid curve is the exact lower bound 1 − (1 − p)N; the dashed curve is the slightly weaker 1 − e−pN we use to pick N. At N = 1/p = 45 you are near 1 − 1/e ≈ 0.6362. Every extra multiple of 1/p multiplies the failure probability by about 1/e.
Worked example. n = 10: N = 100 runs give success ≥ 0.8943. For ≥ 0.99, solve e−N/45 ≤ 0.01 to get N ≥ 45 ln 100, so N = 208 works (the exact minimum is 205). n = 1000, α = 1 (board version): N = n(n−1) ln n ≈ 6,900,848 runs, failure ≤ n−2 = 1.000×10-6: “one minus one in a million”. That's polynomially many runs.
▶ Widget: boosting, success after N independent runs
Traps
  • 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).
✍ 4.4How many runs for n = 10? calcexam-style ⚑ Flagged in lecture · I17
Source: Exam-style variant of the Nov 3 boosting calculation
Karger on n = 10 vertices succeeds with probability at least p = 2/(n(n−1)).
  1. Compute p.
  2. Lower-bound the success probability after N = 45 and after N = 100 independent runs (keeping the smallest cut).
  3. Give a number of runs that guarantees success ≥ 0.99, using (1 − p)N ≤ e−pN.
Show solution
  1. p = 2/90 = 1/45.
  2. 1 − (1 − p)N: N = 45 gives ≥ 0.6362 (about 1 − 1/e, since N = 1/p); N = 100 gives ≥ 0.8943.
  3. 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.
✍ 4.5n = 1000: the lecture's numbers calc ⚑ Flagged in lecture · I17 I20
Source: Nov 3 lecture (“If n is 1,000 and you pick α = 1…”) + Lec 17 typed notes
For n = 1000, p = 2/(n(n−1)).
  1. Show that N = α·n(n−1)·ln n runs give failure ≤ n−2α. Evaluate for α = 1.
  2. The typed notes use N = ⌈α·n(n−1)/2·ln n⌉ and get failure ≤ n−α. Reconcile the two.
  3. How many runs is that, and is it polynomial?
Show solution
  1. (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.
  2. 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.
  3. 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.
✍ 4.6Slide exercise: from 1/n² to failure 1/n³ calcproof ⚑ Flagged in lecture · I17
Source: Lec 17 typed notes, Exercise 1 (verbatim)
If one randomized trial succeeds with probability at least 1/n², how many independent repetitions suffice to make failure probability at most 1/n³?
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.

✍ 4.7“Run until it outputs a min cut”? short answer ⚑ Flagged in lecture · I18
Source: Nov 3 lecture: “I'm going to put ‘until’ in red because we'll come back to that”
The first idea was to “run Karger until it outputs a min cut”. Why doesn't that work as an algorithm, and what do we do instead? What property of cuts makes the fix work?
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”).

✍ 4.8True/False: Karger and boosting T/F ⚑ Flagged in lecture · I17 I16
Source: Exam-style, from Oct 29 / Nov 3 lectures
  1. The watermelon algorithm is a Las Vegas algorithm.
  2. If an algorithm succeeds with probability p = 1/n⁵ and runs in polynomial time, polynomially many repetitions give success probability 1 − o(1).
  3. If an algorithm succeeds with probability 2−n, repeating it polynomially many times gives success 1 − o(1).
  4. Repeating Karger n(n−1) ln n times and keeping the smallest cut always returns a minimum cut.
  5. In Karger's analysis, the probability that the k-th contraction avoids Δ (given the past was good) gets smaller as k grows.
  6. 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
  1. False. Monte Carlo: it may return a non-minimum cut. Its running time is fixed (n − 2 contractions).
  2. True. p⁻¹ = n⁵ is polynomial; N = n⁵·c·ln n runs give failure ≤ n−c (the boosting principle).
  3. False. You'd need about 2ⁿ runs to make (1 − 2−n)N small. That isn't polynomial.
  4. False. Failure probability ≤ 1/n², not 0: it's “with high probability”, not “always”.
  5. True. The bound 1 − 2/(n−k+1) shrinks as fewer vertices remain. The professor: “at the end you need to get really lucky.”
  6. 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.
Recall check (answer aloud, then open)
The three steps of the Karger proof?
(1) avoiding Δ preserves Δ; (2) deg ≥ λ ⇒ |Δ|/Ek ≤ 2/(#vertices); (3) multiply the conditional bounds, telescoping to 2/(n(n−1)).
Success after N runs?
≥ 1 − (1 − p)N ≥ 1 − e−pN.
Runs to get failure ≤ δ?
N = ⌈ln(1/δ)/p⌉; for Karger, n(n−1) ln n runs give ≤ 1/n².
Why can't we stop at the first success?
We can't check minimality, only compare sizes, so we keep the smallest.

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

After this section you can
  • 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.”

u:Av:Asame sideprob 1/4u:Av:Bcrosses ✓prob 1/4u:Bv:Acrosses ✓prob 1/4u:Bv:Bsame sideprob 1/4Pr[edge uv crosses] = 1/4 + 1/4 = 1/2, for every edge, whatever the graph looks like
Each endpoint flips its own fair coin; exactly 2 of the 4 equally likely outcomes put the edge in the cut.
How to read this figure The four equally likely coin outcomes for one edge uv. Two of them (green) split the endpoints. This doesn't depend on the rest of the graph, which is why every edge has the same ½.
Worked example (triangle, m = 3). Of the 8 placements, 2 put everything on one side (cut 0) and 6 give cut 2: Pr[X=0] = 1/4, Pr[X=2] = 3/4. E = 3/2 = m/2 ✓, and Pr[X ≥ 1.5] = 3/4 > 0, so a cut of size ≥ 1.5, hence 2, exists. The three edge indicators are dependent (never all three cross), yet linearity gives the right answer.
Traps Existence is not construction: “we didn't find that cut, we found a random cut.” A single random cut can be tiny. Don't claim Max-Cut ∈ P.
✍ 5.1If E[X] = μ then both sides have positive probability proof ⚑ Flagged in lecture · I21
Source: Nov 3 lecture: “I will not prove this, because it's in your homework”. Proof from MU Lemma 6.2
Let X be a discrete random variable on a probability space with E[X] = μ. Prove Pr[X ≥ μ] > 0 and Pr[X ≤ μ] > 0.
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.

✍ 5.2Expected size of a random cut proofexam-style ⚑ Flagged in lecture · I12 I13
Source: Nov 3 lecture / Lec 17 typed notes §2.1 / MU Thm 6.3
Each vertex of G = (V, E), |E| = m, is placed in A or B by an independent fair coin.
  1. Show that each edge crosses with probability 1/2.
  2. Show E[|C(A,B)|] = m/2.
  3. 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
  1. 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.)
  2. 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.
  3. 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.
✍ 5.6Slide exercise: the indicators are dependent short answer ⚑ Flagged in lecture · I13
Source: Lec 17 typed notes, Exercise 2 (verbatim) + triangle computed in calc.py
Explain why the edge indicators in random Max-Cut need not be independent, even though their expectations can be added. Use a triangle.
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.

✍ 5.7MAX-SAT existence (probabilistic method) proof
Source: MU Thm 6.4 (textbook) + LP4 §7
Show that any CNF formula with m clauses, each with at least k distinct literals (no clause containing both x and ¬x), has an assignment satisfying at least m(1 − 2−k) clauses. How many for m = 40 clauses of exactly 3 literals?
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).

m/2 = E[X] = Σ_{i < m/2} i·Pr[X=i] + Σ_{i ≥ m/2} i·Pr[X=i]small values large valueseach i ≤ ⌈m/2⌉ − 1Σ Pr = Pr[X < m/2] = 1 − peach i ≤ m (all edges cross)Σ Pr = Pr[X ≥ m/2] = p⇒ m/2 ≤ (⌈m/2⌉ − 1)(1 − p) + m·p ⇒ p ≥ 1/(m/2 + 1) (m even), 1/(m + 1) (m odd)
Turning an expectation into a probability lower bound: split the sum at m/2 and replace each value by its largest possible value.
How to read this figure The top line is the definition of E[X], split at m/2. Each half is bounded by (largest possible value) × (total probability of that half). The bottom line is the resulting inequality and the solved bound for p.
Worked example. m = 8: p ≥ 1/5, so you expect ≤ 5 samples (Las Vegas: check each cut by counting). m = 9: p ≥ 1/10, ≤ 10 samples. Triangle (m = 3): the bound says ≥ 1/4; the truth is 3/4.
Traps The lecture's step “every small value ≤ m/2 − 1” assumes m is even. The typed slide states 1/(m/2 + 1) for all m, but for odd m the correct bound is 1/(m + 1) ⚑ Flagged in lecture · I23. Either way it is inverse-polynomial, which is all boosting needs. This yields a ½-approximation with high probability, not the max cut.
✍ 5.3From expectation to probability (max-cut) proofexam-style ⚑ Flagged in lecture · I22 I23
Source: Nov 3 lecture / Lec 17 typed notes §2.2 / MU §6.2.1
Let X = |C(A,B)| for the random cut, p = Pr[X ≥ m/2].
  1. Show p ≥ 1/(m/2 + 1) when m is even.
  2. What does the same argument give for odd m? Evaluate both for m = 8 and m = 9.
  3. 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
  1. 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).
  2. 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.
  3. 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.

v1v2v3v4v5v6A (blue): v1, v3, v4B (orange): v2, v5, v6crossing (red): 7 of 9guarantee m/2 = 4.5
Graph D (m = 9) with the cut produced by the derandomized greedy algorithm (order v1…v6). Red edges cross.
4567Φ09/2Φ19/2Φ25Φ35Φ411/2Φ513/2Φ67m/2Φk = E[cut | placements of v1..vk]; it never goes down, and Φ6 is the actual cut size
Method of conditional expectations on graph D: start at m/2 = 9/2, each greedy placement keeps or raises Φ, finish at 7.
How to read these figures Top: graph D with the cut the greedy rule produced (blue side A, orange side B, red edges cross). Bottom: the value Φk after each placement. It starts at 9/2, never decreases, and ends at the true cut size. Flat steps are vertices whose placed neighbors were evenly split.
Worked example (graph D, order v1…v6). v1: nothing placed, so A. v2: one neighbor in A, so B (Φ: 9/2 → 5). v3: neighbors v1 ∈ A and v2 ∈ B tie, so A (Φ stays 5). v4: neighbor v2 ∈ B, so A (11/2). v5: neighbors v3, v4 ∈ A, so B (13/2). v6: neighbors v4 ∈ A, v5 ∈ B, v1 ∈ A, so B (7). Final cut 7 ≥ 9/2. (Full table in problem 5.4.)
Traps
  • 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.
✍ 5.4Derandomize max-cut by hand calcexam-style ⚑ Flagged in lecture · I24
Source: Nov 3 lecture (greedy placement) on the §5.4 graph D
Graph D has vertices v1..v6 and edges v1v2, v1v3, v2v3, v2v4, v3v5, v4v5, v4v6, v5v6, v1v6 (m = 9). Process the vertices in order v1, …, v6. At each step compute E[cut | placement] for “put vₖ in A” and “put vₖ in B”, choose the larger (ties → A), and report the final cut size.
Show solution
vertexplaced nbrs in A / BE[cut | → A]E[cut | → B]choose
v10 / 09/29/2A
v21 / 045B
v31 / 155A
v40 / 111/29/2A
v52 / 09/213/2B
v62 / 167B

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.

✍ 5.5Slide exercise: the majority rule directly proof ⚑ Flagged in lecture · I24
Source: Lec 17 typed notes, Exercise 3 (verbatim)
Prove directly that assigning each vertex opposite to a majority of its already assigned neighbors produces at least m/2 crossing edges.
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. ∎

✍ 5.8Derandomize MAX-SAT by hand calc
Source: LP4 §7 (method of conditional expectations over variables)
Formula: (x1 ∨ x2) ∧ (¬x1 ∨ x3) ∧ (¬x2 ∨ ¬x3) ∧ (x1) ∧ (¬x1 ∨ ¬x2 ∨ x3). Fix x1, x2, x3 in order. At each step compute the expected number of satisfied clauses if the remaining variables were fair coins, for both choices. Pick the larger (ties → T).
Show solution

Start: E = Σ (1 − 2−kⱼ) = 29/8.

variableE[· | T]E[· | F]choose
x1413/4T
x27/29/2F
x354T

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.

✍ 5.9True/False: probabilistic method T/F ⚑ Flagged in lecture · I25 I26
Source: Exam-style, from Nov 3 lecture
  1. The probabilistic method proof that a cut of size ≥ m/2 exists also tells us how to find it efficiently.
  2. The derandomized max-cut algorithm returns the same cut no matter in which order the vertices are processed.
  3. Max-Cut (find a largest cut) can be solved in polynomial time, just like min-cut.
  4. In the method of conditional expectations, E[cut | x₁] = m/2 for either placement of the first vertex.
  5. 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.
  6. 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
  1. False. Existence only. Finding needs an extra step: the probability bound plus boosting (Las Vegas), or derandomization.
  2. False. Deterministic for a fixed order, but different orders can give different cuts, all with ≥ m/2 edges (Nov 3 recap).
  3. 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.
  4. True. By symmetry: swapping A and B doesn't change the cut size.
  5. True. The number of samples is geometric with mean 1/p ≤ m/2 + 1 (MU §6.2.1).
  6. 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.

A₁A₂A₃Pr[A₁ ∪ A₂ ∪ A₃]≤ Pr[A₁]+Pr[A₂]+Pr[A₃]overlaps get countedmore than oncesum < 1 ⇒ some outcomeavoids every bad event
Union bound (MU §6.1): the bad events can overlap, so adding their probabilities overestimates the chance that any happens.
How to read this figure The box is the whole sample space and each colored oval is a bad event. Adding the areas of the ovals counts the overlaps twice, so the sum is an upper bound on the area they cover. If that sum is below 1 (the area of the box), some point lies outside every oval: a good object.

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.

Trap The union bound needs no independence, but it can exceed 1, in which case it says nothing. Sample-and-modify bounds the expected size after the repair step, not before it.
✍ 5.10Union bound: 2-coloring K₁₀₀₀ (textbook only) textbookcalc
Source: MU §6.1, Thm 6.1 (assigned reading; not covered in lecture)
Color each edge of Kn red or blue by a fair coin. Use the union bound to show that if C(n,k)·2−C(k,2)+1 < 1, some coloring has no monochromatic Kk. Check n = 1000, k = 20.
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. ✓

✍ 5.11Sample and modify: independent sets (textbook only) textbookcalc
Source: MU §6.4.1, Thm 6.5 (assigned reading; not covered in lecture)
G has n = 100 vertices and m = 300 edges. Using MU's sample-and-modify argument (keep each vertex with probability 1/d, d = 2m/n, then delete one endpoint of each surviving edge), what independent-set size is guaranteed to exist?
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.

Recall check (answer aloud, then open)
Why does E[cut] = m/2 imply a cut of size ≥ m/2 exists?
Some outcome is at least the average (otherwise the average would be smaller).
How do you get p ≥ 1/(m/2+1)?
Split E[X] at m/2 and bound the small values by m/2 − 1 and the large ones by m.
Derandomization rule in one sentence?
Place each vertex opposite most of its already-placed neighbors.
Does the vertex order matter?
Different orders can give different cuts, all with ≥ m/2 edges.

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.

After this section you can
  • 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.

k = 1sat 1 − 1/2= 0.5k = 2sat 1 − 1/4= 0.75k = 3sat 1 − 1/8= 0.875k = 4sat 1 − 1/16= 0.9375red = the single all-literals-false setting (prob 2^−k); green = clause satisfied
Fair coins on one clause: only one of the 2^k settings of its variables falsifies it. Unit clauses are the weak spot; k = 3 gives 7/8.
How to read this figure Each bar is one clause of size k. The red slice is the probability that fair coins falsify it (2−k), the green rest is E[Wⱼ]. The smallest green share, ½ at k = 1, is the guarantee for arbitrary formulas.
Worked example (Lec 18 formula). C₁ = (x₁ ∨ ¬x₂), C₂ = (x₂), C₃ = (¬x₁ ∨ ¬x₂). E[W] = ¾ + ½ + ¾ = 2. Brute force gives M* = 2: not all three can hold. Here the fair coin matches OPT in expectation, but a single run might satisfy only 1.
Worked example (LP4 §7). F has m = 12 clauses but at most M* = 10 can be satisfied together. Fair coins give E ≥ 12/2 = 6 ≥ M*/2 = 5. Derandomizing (fix x₁, x₂, … one at a time by the larger conditional expectation; worked by hand in problem 5.8) gives an assignment with ≥ 6 satisfied clauses deterministically, without ever knowing M*.
Traps The weak spot is unit clauses (k = 1: only ½). Assume no clause contains both x and ¬x (that would always be satisfied) and no repeated variable within a clause. The ½ is in expectation.

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.

k = 1sat 1 − 1/2= 0.5k = 2sat 1 − 1/4= 0.75k = 3sat 1 − 1/8= 0.875k = 4sat 1 − 1/16= 0.9375red = the single all-literals-false setting (prob 2^−k); green = clause satisfied
Fair coins on one clause: only one of the 2^k settings of its variables falsifies it. Unit clauses are the weak spot; k = 3 gives 7/8.
How to read this figure Same picture as §6.1. For MAX-E3SAT only the k = 3 bar matters: 1/8 red, 7/8 green, for every clause. With clauses of size 1 or 2 allowed, the k = 1 bar (½) sets the guarantee.
Worked example. 40 clauses of exactly 3 literals: E[satisfied] = 35, so some assignment satisfies at least that many (probabilistic method, MU Thm 6.4).
Trap “MAX-3SAT” with clauses of at most 3 literals only gets ½ from fair coins. Example: (x) ∧ (¬x) has exactly one clause satisfied by every assignment. This is a Lec 18 exercise.
✍ 6.5Slide exercise: why 7/8 needs exactly 3 literals short answer ⚑ Flagged in lecture · I28
Source: Lec 18 typed notes, Exercise 3 (verbatim)
Explain why the 7/8 fair-coin proof does not apply to MAX-3SAT if clauses of size one or two are permitted.
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*.

LP optimum (fractional vertex)best grid point = ILP optimumobjective: maximize x₁ + x₂ (direction ↗)LP: all real points→ value LP* ≥ OPTILP: grid points only→ value OPT (NP-hard)
Relaxation: dropping integrality enlarges the feasible set, so the LP optimum is at least the integer optimum (for a maximization).
How to read this figure The shaded polygon is the LP's feasible region. Black dots are the integer points inside it, the only ones the ILP may use. Pushing the objective up and to the right, the LP stops at a fractional corner (red), and the best integer point (green) is a bit lower. For a maximization, the relaxation's value is always ≥ the integer value.
Worked example (Lec 18 formula). Constraints: z₁ ≤ y₁ + (1 − y₂), z₂ ≤ y₂, z₃ ≤ (1 − y₁) + (1 − y₂). The LP solver gives ŷ1 = 0.5, ŷ2 = 0.5, ẑ1 = 1, ẑ2 = 0.5, ẑ3 = 1, LP* = 2.5 > M* = 2. The LP “cheats” with halves: y₂ = ½ lets C₂ count ½, and both other clauses count fully.
Traps For a negated literal use (1 − yᵢ), not yᵢ. LP* is an upper bound on OPT for a maximization, not a lower bound. The LP has n + m variables and m clause constraints plus bounds: polynomial size.
✍ 6.1Check the ILP clause constraint short answer
Source: Lec 18 typed notes, Exercise 1 (verbatim)
Verify the ILP constraints on the clause (x1 ∨ ¬x2 ∨ x3) for one satisfying and one unsatisfying assignment.
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.

✍ 6.2Write the ILP and the LP relaxation exam-style
Source: LP4 §10–14 / Lec 18 typed notes §1, §3, on the Lec 18 example formula
For C₁ = (x₁ ∨ ¬x₂), C₂ = (x₂), C₃ = (¬x₁ ∨ ¬x₂):
  1. Write the ILP for MAX-SAT and its LP relaxation.
  2. OPT = ? (brute force) LP* = ? (the LP solver gives an optimal solution ŷ1 = 0.5, ŷ2 = 0.5, ẑ1 = 1, ẑ2 = 0.5, ẑ3 = 1)
  3. Why must LP* ≥ OPT?
  4. Compute the expected number of satisfied clauses under fair coins and under LP rounding with this ŷ.
Show solution
  1. 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).
  2. OPT = 2: no assignment satisfies all three. LP* = 2.5.
  3. Every integer solution is LP-feasible and the LP maximizes over a larger set (relaxation).
  4. 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*. ∎

CNF formula Fn vars, m clausesILP (exact)max Σ zjLP relaxationsolve in poly timefractional ŷŷi ∈ [0,1]flip coinsxi = T w.p. ŷiE[# satisfied] = Σj Pr[Cj sat] ≥ Σj (1 − 1/e)·ẑj = (1 − 1/e)·LP* ≥ (1 − 1/e)·OPTper-clause lemma linearity LP* ≥ OPT (relaxation)
Randomized rounding pipeline for MAX-SAT, and the chain of inequalities behind the 1 − 1/e guarantee.
How to read this figure Left to right is the algorithm; only the boxes from “LP relaxation” on run in polynomial time. The inequality chain underneath is the proof: the per-clause lemma, then linearity, then the relaxation inequality LP* ≥ OPT.
000.50.511z = ẑj (LP value of the clause)1 − (1 − z/2)² (k = 2)1 − (1 − z/3)³ (k = 3)1 − e^(−z)chord from (0,0) to (1, f(1))concave curve ≥ its chord on [0,1]⇒ f(z) ≥ f(1)·z
Why the bound becomes linear in ẑj: each curve is concave, so on [0,1] it stays above the straight chord to its value at 1.
How to read this figure Each solid curve is a lower bound on Pr[clause satisfied] as a function of the clause's LP value z. Each dashed chord joins (0,0) to the curve's value at z = 1. Concave curves stay above their chords on [0,1], which makes the bound linear in z: f(z) ≥ f(1)·z.
Worked example. Clause (x₁ ∨ x₂ ∨ x₃), ŷ = (0.5, 0.3, 0.2), ẑ = 1. Exact: 1 − 0.5·0.7·0.8 = 0.7200 ≥ AM–GM bound 0.7037 ≥ 1 − 1/e = 0.6321. Negated clause (¬x₁ ∨ ¬x₂) with ŷ = (0.9, 0.6): ẑ ≤ 0.1 + 0.4 = 0.5000, Pr[sat] = 1 − 0.9·0.6 = 0.4600 ≥ β₂ẑ = 0.3750.
▶ Widget: randomized rounding simulator (formula R from §6.4)
Each variable is set true with probability pi = (1 − λ)·½ + λ·ŷi. λ = 0 is fair coins, λ = 1 is LP rounding.
The general recipe (for “another problem” on the homework/exam) 1) Write the problem as an ILP with 0/1 variables. 2) Relax to an LP and solve it (OPT ≤ LP* for a max, ≥ for a min). 3) Round each variable to 1 independently with probability equal to its LP value. 4) Bound the probability that each constraint/term “counts” in terms of its LP contribution, using independence for products, AM–GM, concavity, and 1 − x ≤ e−x. 5) Linearity, then LP* vs OPT.
Traps
  • 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.
✍ 6.3One clause, fractional values calc
Source: LP4 §17–21 lemma, numeric instance
LP solution ŷ₁ = 0.5, ŷ₂ = 0.3, ŷ₃ = 0.2, ẑ = 1 for the clause (x₁ ∨ x₂ ∨ x₃).
  1. Exact Pr[clause satisfied] after randomized rounding?
  2. Compare with the AM–GM bound 1 − (1 − ẑ/k)k, with β₃ẑ, and with (1 − 1/e)ẑ.
  3. Now the clause (¬x₁ ∨ ¬x₂) with ŷ₁ = 0.9, ŷ₂ = 0.6. What is the largest feasible ẑ, and Pr[satisfied]? Check it is ≥ β₂ẑ.
Show solution
  1. Fails only if all three are false: 0.5·0.7·0.8 = 0.2800, so Pr = 0.7200.
  2. 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.
  3. ẑ ≤ (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.)
✍ 6.4Slide exercise: concavity without derivatives proof
Source: Lec 18 typed notes, Exercise 2 (verbatim)
Prove that 1 − e−z ≥ (1 − 1/e)z for 0 ≤ z ≤ 1 without differentiation, using concavity.
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).)

✍ 6.8Prove the rounding lemma proofexam-style
Source: LP4 §17–21 / Lec 18 typed notes §3
Let (ŷ, ẑ) be an optimal LP solution and round each xᵢ to true independently with probability ŷᵢ. Prove that every clause Cⱼ satisfies Pr[Cⱼ satisfied] ≥ (1 − 1/e)ẑⱼ, and conclude E[#satisfied] ≥ (1 − 1/e)·OPT.
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. ∎

✍ 6.9Rounding on formula R calc
Source: Worked instance (LP solved with scipy in calc.py; same formula as the simulator widget)
R = (x1) ∧ (x2) ∧ (¬x1 ∨ ¬x2) ∧ (x1 ∨ ¬x3) ∧ (x3 ∨ ¬x2) ∧ (¬x3) ∧ (x2 ∨ x3 ∨ ¬x1). The LP optimum is LP* = 5.66667 with ŷ1 = 0.666667, ŷ2 = 0.333333, ŷ3 = 0.333333.
  1. Brute-force OPT is 5. Confirm LP* ≥ OPT makes sense.
  2. Expected satisfied clauses: fair coins = 37/8; LP rounding = 4.8148. Which guarantees do these numbers respect?
  3. What does the best-of-two algorithm guarantee here?
Show solution
  1. The LP is a relaxation, so its value can exceed the best integer value (5.66667 > 5).
  2. Fair: 37/8 ≥ m/2 = 3.5. LP rounding: 4.8148 ≥ (1 − 1/e)·LP* = 3.5820 ≥ (1 − 1/e)·OPT.
  3. E[max] ≥ average = 4.7199 ≥ ¾·LP* = 4.2500.
✍ 6.10Why not round deterministically? short answerchallenge ⚑ Flagged in lecture · I27
Source: Derived example (recipe practice for “another problem”, see the Nov 3 homework remark)
Instead of coins, set xᵢ = T iff ŷᵢ ≥ ½. Give a clause where this can satisfy nothing even though ẑ = 1, while randomized rounding satisfies it with probability ≥ 1 − 1/e.
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 kfair coins αₖLP rounding βₖbetterαₖ + βₖ
11/2111.5000
23/43/43/41.5000
37/819/27 ≈ 0.70377/81.5787
415/16≈ 0.683615/161.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). ∎

0.40.50.60.70.80.91.0k=1k=2k=3k=4k=5k=63/41 − 1/efair coins: 1 − 2^−kLP rounding: 1 − (1 − 1/k)^k
Per-clause guarantees by clause size k. They cross at k = 2 (both 3/4). The better of the two is always ≥ 3/4.
How to read this figure Blue is the fair-coin guarantee per clause size, orange is the LP-rounding guarantee. They cross at k = 2, where both equal ¾. The higher curve is never below the ¾ line, but the proof uses the average of the two curves, which is also ≥ ¾.
Worked example (formula R, the simulator's formula). m = 7, OPT = 5, LP* = 5.66667. E[fair] = 4.6250, E[LP rounding] = 4.8148, average 4.7199 ≥ ¾·LP* = 4.2500. ✓
Trap The video says “for each clause, take the better algorithm”, which proves nothing, because the algorithm picks one whole assignment. Use the averaging argument ⚑ Flagged in lecture · I30.
✍ 6.6Fill the comparison table calc
Source: LP4 §23 table
For clause size k = 1, 2, 3, 4, give the fair-coin guarantee αₖ = 1 − 2−k, the LP-rounding factor βₖ = 1 − (1 − 1/k)k, the better of the two, and αₖ + βₖ.
Show solution
kαₖβₖmaxαₖ + βₖ
11/2 = 0.50001 = 1.00001.00001.5000
23/4 = 0.75003/4 = 0.75000.75001.5000
37/8 = 0.875019/27 = 0.70370.87501.5787
415/16 = 0.9375175/256 = 0.68360.93751.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.

✍ 6.7The ¾-approximation, proved correctly proofexam-style ⚑ Flagged in lecture · I30
Source: LP4 §24 + the transcript's editorial correction (the video's per-clause argument is not a valid proof)
Algorithm: run fair coins (M₁ satisfied) and LP rounding (M₂ satisfied); output the better assignment. Prove E[max(M₁, M₂)] ≥ ¾·OPT, using αₖ + βₖ ≥ 3/2 for all k ≥ 1.
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.

✍ 6.11True/False: rounding and MAX-SAT T/F ⚑ Flagged in lecture · I29 I31 I28
Source: Exam-style, from LP4 + Lec 18 typed notes
  1. Each run of LP-guided rounding satisfies at least (1 − 1/e)·OPT clauses.
  2. For a maximization ILP, the LP relaxation's optimal value is at most the ILP's optimal value.
  3. In MAX-SAT randomized rounding we must also round the zⱼ variables.
  4. A polynomial-time 0.88-approximation for MAX-E3SAT would imply P = NP.
  5. Fair coins give a 7/8-approximation for MAX-3SAT when clauses have at most 3 literals.
  6. 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
  1. False. The guarantee is in expectation; a single run can be lower (Lec 18 typed notes).
  2. False. It's at least: the relaxation has more feasible points (LP* ≥ OPT).
  3. False. Only the yᵢ are rounded. The resulting assignment determines which clauses are satisfied.
  4. True. Håstad: doing better than 7/8 is NP-hard, and 0.88 > 0.875.
  5. False. 7/8 needs exactly 3 distinct literals per clause; unit clauses are satisfied with probability only ½.
  6. 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.

Worked example (Exam 2 Q1(f)). A greedy 2-approximation for Vertex Cover returns a cover of size 20, and G contains a matching of size 8. Upper: OPT ≤ 20 (rule 1, the cover is feasible). Lower: 20 ≤ 2·OPT ⇒ OPT ≥ 10 (rule 2). The matching gives OPT ≥ 8 (every matching edge needs its own cover vertex), which is weaker than 10. Answer: 10 ≤ OPT ≤ 20.
Traps
  • 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.
✍ 6.12Strongest bounds on OPT (Q1(f) drill) exam-stylebounds ⚑ Past exam / HW · I79
Source: Exam 2 Q1(f) format (8 points); my numbers
For each, give the strongest lower and upper bound on OPT that follows, with one sentence of justification.
  1. A Set Cover instance: the LP relaxation has optimal value 7.4, and randomized rounding + repetition returned a cover with 19 sets.
  2. 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.
  3. 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
  1. 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.
  2. 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.
  3. 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.
Recall check (answer aloud, then open)
The four steps of the rounding lemma?
Product of miss probabilities → AM–GM → LP constraint Σ ≥ ẑ → concavity + (1 − 1/k)k ≤ 1/e.
When does 7/8 hold?
Only when every clause has exactly 3 distinct literals.
Why average in the ¾ proof?
max ≥ average; the algorithm can't pick the better method per clause.
Min problem: a 2-approx returns 20. Bounds?
10 ≤ OPT ≤ 20: the solution gives the upper bound, the guarantee the lower.
Which variables get rounded?
Only the yᵢ, independently with probability ŷᵢ.

7 · Formula and bounds table

Everything you might need to write from memory, or put on a note sheet. Numbers come from calc.py.

PieceFormulaIn plain words
Bernoulli(p)Pr[X=1] = p, Pr[X=0] = 1−p, E = pOne trial: success or not
Binomial(n,p)Pr[X=k] = C(n,k)pk(1−p)n−k, E = npNumber 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)NTrials until the first success. “Repeat until it works.”
ExpectationE[X] = Σₓ x·Pr[X=x]Probability-weighted average
IndicatorE[I] = Pr[I = 1]The expectation of a 0/1 variable is the chance it's 1
LinearityE[ΣXᵢ] = ΣE[Xᵢ] (no independence needed)Break a count into indicators, sum their probabilities
MarkovX ≥ 0, a > 0: Pr[X ≥ a] ≤ E[X]/aBeing a times the mean is at most 1/a likely. Loose.
Chain rulePr[E₁∩⋯∩Et] = ∏ Pr[Eᵢ | E₁…Ei−1]Multiply step-by-step chances, each given the good past
Disjoint eventsPr[∪Aᵢ] = ΣPr[Aᵢ] ≤ 1One run returns one cut ⇒ #min cuts ≤ n(n−1)/2 (§15.1)
Tail sumE[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 bound1 − x ≤ e−x; (1 − 1/n)n ≤ 1/e; (1 − p)N ≤ e−pNTurns 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 methodE[X] = μ ⇒ Pr[X ≥ μ] > 0 and Pr[X ≤ μ] > 0Some outcome is at least the average, so a good object exists
Karger, one runPr[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
BoostingPr[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 cutPr[edge crosses] = ½; E[cut] = m/2Every graph has a cut ≥ m/2. Expected ½-approximation for Max-Cut
Large-cut probabilityPr[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) ≤ maxPick the side that keeps the expectation from dropping: greedy
Fair-coin MAX-SATPr[Cⱼ sat] = 1 − 2−kⱼ ≥ ½; E ≥ m/2½-approximation; 7/8 for exactly-3 clauses (optimal unless P = NP)
MAX-SAT ILPmax Σzⱼ, zⱼ ≤ ΣCⱼ⁺yᵢ + ΣCⱼ⁻(1−yᵢ), y,z ∈ {0,1}zⱼ is forced to 0 exactly when every literal is false
RelaxationLP* ≥ OPT (max problem); LP* ≤ OPT (min problem)More feasible points can only help
AM–GM∏wᵢ ≤ ((1/k)Σwᵢ)k, wᵢ ≥ 0Turns the product of failure probabilities into the sum the LP controls
Rounding lemmaPr[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 trickf concave, f(0) = 0 ⇒ f(z) ≥ f(1)·z on [0,1]A concave curve lies above its chord
Best of twoE[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 + repetitionPr[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 protocolPr[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 OPTmax: v ≤ OPT ≤ min(v/α, LP*); min: max(v/α, LP*) ≤ OPT ≤ vA solution bounds one side; a guarantee or relaxation the other (§6.6)
Reduction A → Bf, g poly time; I solvable ⇔ f(I) solvable; g(S) solves IB is at least as hard as A
What it preservesA NP-hard ⇒ B NP-hard; B ∈ P ⇒ A ∈ P; both ⇒ P = NPHardness flows forward, easiness backward
ClassesP ⊆ NP; NP-complete = NP ∩ NP-hardNP = verifiable in poly time (search problems); P = solvable. NP = nondeterministic poly time
NP-complete proofB ∈ NP + (known NP-complete K) → BEvery A ∈ NP: A → K → B by composition. FROM the known TO the new
Clause splittingk 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 → aUnsatisfiable ⇔ some x and ¬x share an SCC. Assign: sink SCC true, its complement false, repeat (GR2)
3-SAT → ISvertex per literal occurrence; clause cliques + complement edges; k = mOne true literal per clause, no contradictions
IS / Clique / VCS indep in G ⇔ S clique in Ĝ ⇔ V∖S vertex cover of GOne 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.

NP (search problems:poly-time verifier)P (poly-time solvable)shortest path2-SATbipartite matchingmax-flow / min s-t cutglobal min-cutLPNP-hard(everything in NP reduces to it)NP-complete= NP ∩ NP-hardSAT, 3-SATInd. Set, CliqueVertex CoverMax-SAT (optimization)ILP (optimization)Max-Cut (optimization)knapsack (optimization, not a search problem in class)Drawn assuming P ≠ NP (unknown!). If P = NP, the P and NP regions coincide.
The four classes from lecture (Lec 19 board: P inside NP, NP-hard overlapping NP, NP-complete shaded overlap).
How to read this figure The blue oval is NP: every search problem, i.e. a proposed solution can be checked in polynomial time. The green oval inside it is P, the problems we can also solve in polynomial time. The red region is NP-hard: everything in NP reduces to these problems. Its overlap with NP is NP-complete. Problems on the far right are NP-hard but, as optimization problems, not search problems in the class's sense. The picture assumes P ≠ NP; nobody knows.
Cook–Levinsplit clausessame formulay, z varsclause cliquescomplement graphS ↦ V∖Ss,t + cap 1implication graphany problem in NPCircuit-SAT†SAT3-SATMax-SATILPIndependent SetCliqueVertex CoverSet Packing†Set Cover†Bipartite MatchingMax-Flow (P)2-SATSCCs (P)easy side:reduce TO P⇒ in PA → B: B isat least as hardsolid = shown in lecture / LP4 · dashed † = textbook only (Kleinberg–Tardos ch. 8) · green = reductions to problems in P
Map of the reductions in this unit. Arrows point from the known problem to the new one: hardness flows along the arrows.
How to read this figure An arrow X → Y means “X reduces to Y” (an algorithm for Y solves X). Follow the arrows from SAT and every red box is NP-hard. Green arrows go into easy problems and prove easiness (matching, 2-SAT). Solid arrows were done in lecture or LP4; dashed † arrows are only in Kleinberg–Tardos ch. 8.
Trap Arrows are one-way. IS → SAT also exists (IS ∈ NP, Cook–Levin), but it is not 3-SAT → IS reversed ⚑ Flagged in lecture · I41.

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.

After this section you can
  • 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.

2ⁿn³n²n010203010⁴0input size n (values capped at 10⁴)
Polynomials (green, blue, orange) stay manageable; 2ⁿ (red) leaves the chart before n = 14.
How to read this figure The four curves share one axis, with values capped at 10,000. The polynomials grow, but stay on the chart for every n shown. 2ⁿ passes 10,000 near n = 13.3. Nesting loops multiplies exponents (n·n² = n³) and stays in the polynomial family; exponentials do not.
Worked example. f runs in O(n²), B is solvable in O(N³): solving A via B costs O((n²)³) = O(n6), plus O(n²) for f. Polynomial.
Trap Polynomial in the input size (bits). Knapsack's O(nB) DP is pseudo-polynomial: B is exponential in its bit length (Unit 1). Trial division up to √n is also exponential in the number of bits.
✍ 9.8Why polynomial time composes short answer
Source: Nov 10 lecture (“composing efficient steps is efficient”)
A reduction's f runs in O(n²) time on inputs of size n, and B can be solved in O(N³) time on inputs of size N. Bound the time to solve A this way (ignore g). Why is this the whole reason reductions use 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.)

NP (search problems:poly-time verifier)P (poly-time solvable)shortest path2-SATbipartite matchingmax-flow / min s-t cutglobal min-cutLPNP-hard(everything in NP reduces to it)NP-complete= NP ∩ NP-hardSAT, 3-SATInd. Set, CliqueVertex CoverMax-SAT (optimization)ILP (optimization)Max-Cut (optimization)knapsack (optimization, not a search problem in class)Drawn assuming P ≠ NP (unknown!). If P = NP, the P and NP regions coincide.
The four classes from lecture (Lec 19 board: P inside NP, NP-hard overlapping NP, NP-complete shaded overlap).

How to read this figure Same picture as §8 (it is the Nov 10 board's diagram). Read “inside the blue oval” as “has a poly-time verifier”, “inside green” as “has a poly-time algorithm”, and “inside red” as “everything in NP reduces to it”.
Worked example: knapsack. “I think this subset is the most profitable for capacity B.” To check optimality we would need the best possible profit. Our DP takes O(nB) time, which is pseudo-polynomial (it depends on B, not on log B), so we can't use it to verify in polynomial time. The lecture: “We don't know how to verify (optimization) knapsack in polynomial time, at least not yet. So knapsack, as we saw it in class, is not a search problem.” The NP1 video says the same thing more carefully: knapsack is not known to be in NP and not known to be in P video ⚑ Flagged in lecture · I37 ⚑ OMS video (extra) · I72. Exam wording: “not known to be in NP: no polynomial-time verifier of optimality is known.” Don't write “knapsack is provably not in NP”. Proving that would prove P ≠ NP.

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:

ProblemVerifier (what you write)Time
SATFor each of the m clauses, check that some literal is true under the assignment.O(nm)
3-SATSame, but each clause has ≤ 3 literals.O(m)
k-coloringFor 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)
MSTCheck 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-searchCheck Σ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.)

Worked example: binary search on g. Items (w, v) = (3, 4), (4, 5), (2, 3), (5, 8), B = 9, so V = 20. The box is asked 5 times (bound ⌈log₂ 21⌉ = 5) and pins the optimum at 13. The box's answer for g = 13 is items {2, 4}: a search answer at the optimal goal is an optimal subset. (Simulated in calc.py.)

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.

Traps
  • 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.
✍ 9.1Definitions, in the course's words short answer ⚑ Flagged in lecture · I37 I38
Source: Nov 10 lecture / board
Define: search problem, NP, P, NP-hard, NP-complete. Then answer: is every NP-hard problem in NP?
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.

✍ 9.2In NP or not (course definition)? short answer ⚑ Flagged in lecture · I37
Source: Nov 10 lecture examples (shortest path, independent set, knapsack) + LP4 §1
Using “NP = search problems with a poly-time verifier”, decide whether each is in NP, and say whether it is known to be in P.
  1. Shortest s–t path.
  2. Independent set: given G and k, find an independent set of size ≥ k.
  3. Knapsack as in class: find the most valuable subset within capacity B.
  4. Max-SAT: find an assignment maximizing the number of satisfied clauses.
  5. 2-SAT.
Show solution
  1. In NP (checking a path's length against a shortest-path computation is poly) and in P.
  2. In NP: count the vertices and check no edge inside. Poly-time solvability is unknown; it's NP-complete.
  3. 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).
  4. Not in NP as an optimization problem (you can't check that the count is maximum), but NP-hard (SAT → Max-SAT).
  5. In NP and in P (SCCs of the implication graph).
✍ 9.10Knapsack-search and binary search short answerexam-stylevideo ⚑ OMS video (extra) · I72
Source: OMS NP1 video, sections 15–17 (extra material); example numbers simulated in calc.py
Knapsack-search: input weights w₁..wₙ, values v₁..vₙ, capacity B and a goal g. Output a subset S with Σi∈Swᵢ ≤ B and Σi∈Svᵢ ≥ g, or NO.
  1. (2) Show knapsack-search is in NP.
  2. (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?
  3. (1) Why does the definition say value ≥ g and not value ≤ g?
  4. (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?
  5. (2) Is optimization knapsack in NP? Answer in the course's terms.
Show solution
  1. 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.
  2. 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.
  3. “≤ g” would be trivial: the empty set always has value 0 ≤ g. We want to push the value up.
  4. 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).
  5. 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.)
✍ 9.11Select all: search problems, P and NP select-allvideo ⚑ OMS video (extra) · I71 I73 I74 I70
Source: OMS NP1 video quizzes (MST, knapsack, SAT verification, the NP acronym, direction) in the Exam 2 select-all format

Select ALL that apply.

⃝ MST is in NP.
⃝ MST is in P.
⃝ Knapsack (optimization, as in class) is known to be in NP.
⃝ “NP” stands for “not polynomial time”.
⃝ Checking that an assignment satisfies a CNF formula with n variables and m clauses takes O(nm) time.
⃝ If P ≠ NP, then no NP-complete problem can be solved in polynomial time.
⃝ To show B is NP-complete it suffices to show B ∈ NP and B reduces to SAT.
Show solution

Correct: 1, 2, 5, 6

  1. ✔ Verify T is a spanning tree (BFS/DFS) and compare its weight with Kruskal's/Prim's MST: O(m log n).
  2. ✔ Kruskal/Prim find it in polynomial time.
  3. ✘ Not known: verifying optimality needs the pseudo-polynomial DP.
  4. ✘ Nondeterministic polynomial time. P ⊆ NP.
  5. ✔ Each clause has at most 2n literals, so O(n) per clause, m clauses (NP1 video).
  6. ✔ If one NP-complete problem were in P, every NP problem would be (all reduce to it), so P = NP. Contrapositive.
  7. ✘ 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).

input Iof problem Afblack box solving B(“tesseract”)input f(I) → solution Sor NOgg(S): solutionof INO ⇒ I has noneRequirements: f, g poly time · I has a solution ⇔ f(I) has a solution · g(S) solves I
A reduction A → B (Lec 19 board). It lets you solve A using any solver for B, so B is at least as hard as A.
How to read this figure Follow I from the left. f converts it, the box for B solves it, and g converts the solution back. The red lower path is the NO case: because of the ⇔, a NO from B means a NO for A. Every arrow must be a polynomial-time computation.
Worked example: the fake reduction. Map every input of any problem to K2026 with s = 1, t = 2, and ask for a shortest path. The box always answers “edge 1–2”. This fails twice: the ⇔ fails (an unsolvable I maps to a solvable f(I)), and no g can recover a solution of I from that edge. “f must be connected to g in a very specific way” ⚑ Flagged in lecture · I36.
Traps Forgetting g (the course's search definition needs recovery). Proving only one direction of the ⇔. Letting f take exponential time, e.g. by solving A inside f.
✍ 9.6Why is this “reduction” invalid? short answer ⚑ Flagged in lecture · I36
Source: Nov 10 lecture (the K2026 magic trick)
“Reduce” any problem A to shortest path: f maps every input I of A to the complete graph on 2026 vertices with s = 1, t = 2. Run shortest path. Why is this not a reduction?
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.

A(source)B(target)reduction A → BNP-hardness flows forwardmembership in P flows backwardA NP-hard and B ∈ P together ⇒ P = NP
What a reduction A → B transfers (Lec 20 summary). Nothing flows the other way.
How to read this figure The thick arrow is the reduction. Red: if the source is NP-hard, so is the target. Green: if the target is in P, so is the source. Nothing travels the other way along either color.
Worked example. “Show Clique is NP-hard.” Right: IS → Clique (IS known hard). Wrong: Clique → IS. That only shows IS is at least as hard as Clique, which we already knew.
Mnemonic “FROM the known, TO the new.” Say it out loud before every reduction answer.
✍ 9.3Direction of the reduction MCQ ⚑ Flagged in lecture · I33
Source: Nov 10 Q&A: “that's a great multiple-choice question to think about”
You want to prove a new problem B is NP-hard and you know A is NP-hard. Which do you show?
  1. B reduces to A.
  2. A reduces to B.
  3. Either direction works.
  4. Both directions are needed.
Also: shortest path reduces to SAT. Does SAT reduce to shortest path?
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):

KnownConcludeWhy
A is NP-hardB is NP-hardEverything → A → B (transitivity)
B ∈ PA ∈ PSolve A by f, B's algorithm, g, all polynomial
A NP-hard and B ∈ PP = NPEverything → A, which is now poly time
A ∈ Pnothing about BEasy problems reduce to hard ones (shortest path → SAT)
B NP-hardnothing about AEvery NP problem reduces to an NP-hard B
A(source)B(target)reduction A → BNP-hardness flows forwardmembership in P flows backwardA NP-hard and B ∈ P together ⇒ P = NP
What a reduction A → B transfers (Lec 20 summary). Nothing flows the other way.
How to read this figure Each table row is one arrow in this picture. A red conclusion needs NP-hardness at the source; a green conclusion needs membership in P at the target. The bottom line is the row where both happen at once.
Worked example (Nov 12). Bipartite matching → max-flow, and max-flow ∈ P, so matching ∈ P (row 2). SAT → Max-SAT with SAT NP-hard, so Max-SAT is NP-hard (row 1).
Trap “A → B and B is NP-hard, so A is NP-hard” is the most common wrong conclusion.
✍ 9.4What follows from A → B? short answerexam-style ⚑ Flagged in lecture · I40 I03
Source: Nov 12 summary (“what does a reduction preserve?”)
Suppose A reduces to B in polynomial time. For each extra fact, state what you can conclude (or “nothing”).
  1. A is NP-hard.
  2. B ∈ P.
  3. A ∈ P.
  4. B is NP-hard.
  5. B ∈ NP and A is NP-hard.
Show solution
  1. B is NP-hard.
  2. A ∈ P (solve A by f, then B's algorithm, then g).
  3. Nothing about B. Easy problems reduce to hard ones all the time.
  4. Nothing about A. Everything in NP reduces to an NP-hard B, easy problems included.
  5. B is NP-hard (from A) and in NP, so B is NP-complete.
✍ 9.5The dramatic case short answer ⚑ Flagged in lecture · I56
Source: Nov 12: “if A is NP-hard and B is in P, then?”
A is NP-hard, B ∈ P, and A reduces to B. What follows?
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.)

✍ 9.7True/False: P, NP, reductions T/F ⚑ Flagged in lecture · I33 I35 I38 I39 I34
Source: Exam-style, from Nov 10 Q&A
  1. In a reduction A → B, the map f must be injective (one-to-one).
  2. NP-hard problems cannot be solved in polynomial time.
  3. P ⊆ NP.
  4. Every NP-hard problem belongs to NP.
  5. The functions f and g in a reduction can be chosen independently of A and B.
  6. If one NP-complete problem has a polynomial-time algorithm, then P = NP.
  7. 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
  1. False. No restriction beyond: I solvable ⇔ f(I) solvable, g recovers a solution, f and g poly time (Nov 10 Q&A).
  2. False. Unknown. We don't know how to; doing so would prove P = NP (Nov 10 Q&A: “We don't know yet”).
  3. True. A problem we can solve in poly time can be verified by solving it (KT 8.10).
  4. False. NP-hard problems “don't have to be search problems” (e.g. optimization Max-SAT, ILP).
  5. False. “They very much depend on A and B.”
  6. True. Everything in NP reduces to it (KT 8.12; Nov 10 lecture).
  7. 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”).

step 1012345678ask k=4: yesstep 2012345678ask k=6: nostep 3012345678ask k=5: yesgreen = still-possible values of the maximum; O(log n) questions find it (here: 5)
From a yes/no box to the optimum: binary search on k (KT §8.1).
How to read this figure Each row is one question to the yes/no box. Green cells are the values the maximum can still have. “Yes at k” removes everything below k; “no at k” removes k and above. Three questions pin the maximum at 5.
Worked example. n = 8, true maximum 5. Ask k = 4: yes. Ask 6: no. Ask 5: yes. So the maximum is 5. Then, for each vertex v, ask “does G − v still have an independent set of size 5?” and delete v whenever the answer is yes. The survivors form an independent set of size 5.
Trap If an exam question is phrased as a decision problem, your reduction still needs the ⇔. You just don't need g.
✍ 9.9Decision vs. search (self-reducibility) challenge ⚑ Flagged in lecture · I57
Source: Nov 12 opening (“for your own entertainment”) + KT §8.1 binary-search remark; the vertex-deletion step is a derivation, not from the materials
Suppose a black box answers “does G have an independent set of size ≥ k?”.
  1. Find the size of a maximum independent set with O(log n) calls.
  2. Then find an actual maximum independent set with polynomially many calls.
Show solution
  1. Binary search on k ∈ [0, n] (KT §8.1).
  2. 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.)
Recall check (answer aloud, then open)
To show B is NP-hard, which direction do you reduce?
From a known NP-hard A to B: A → B.
A NP-hard, A → B, B ∈ P. Conclusion?
P = NP.
Is every NP-hard problem in NP?
No. Example: Max-SAT as an optimization problem.
Is knapsack in NP? Knapsack-search?
Knapsack (optimization): not known (no poly-time optimality check). Knapsack-search (value ≥ g): yes, check two sums.
Does f have to be injective?
No. Only the ⇔, recovery by g, and polynomial time matter.

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

After this section you can
  • 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.

x₁ ∨ ¬x₂x₂¬x₁ ∨ ¬x₂∧∧clause = OR of literals∧ = AND between clausesliteral: a variable (x₁) or its negation (¬x₂)satisfied ⇔ every clause has ≥ 1 true literalMax-SAT: maximize the number of satisfied clauses (here at most 2 of 3)
Anatomy of a CNF formula (the Lec 18 example).
How to read this figure The blue underline marks one clause (literals joined by OR), and the orange mark is an AND between clauses. To satisfy the formula, pick values so that every clause contains at least one true literal.
Worked example. (x₁ ∨ ¬x₂) ∧ (x₂) ∧ (¬x₁ ∨ ¬x₂) is not satisfiable: x₂ must be T, then the clauses force x₁ = T and x₁ = F. Its Max-SAT optimum is 2 of 3.
Trap Read “3-SAT” in a question carefully. The board defines k-SAT as “at most k”; KT means “exactly 3”. For hardness proofs it makes no difference. For the 7/8 approximation it matters (§6.2).

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.”

Cook–Levinsplit clausessame formulay, z varsclause cliquescomplement graphS ↦ V∖Ss,t + cap 1implication graphany problem in NPCircuit-SAT†SAT3-SATMax-SATILPIndependent SetCliqueVertex CoverSet Packing†Set Cover†Bipartite MatchingMax-Flow (P)2-SATSCCs (P)easy side:reduce TO P⇒ in PA → B: B isat least as hardsolid = shown in lecture / LP4 · dashed † = textbook only (Kleinberg–Tardos ch. 8) · green = reductions to problems in P
Map of the reductions in this unit. Arrows point from the known problem to the new one: hardness flows along the arrows.
How to read this figure Look at the top row: SAT → Max-SAT (same formula) → ILP (y, z variables). Each arrow is a reduction you should be able to write, and hardness flows to the right.
Traps The direction is SAT → Max-SAT, not the reverse. Max-SAT is NP-hard, not NP-complete: as an optimization problem it isn't in NP, because you can't verify maximality. Don't forget the “no” case in g.
✍ 10.1Why is Max-SAT hard? (predicted exam question) reductionexam-style ⚑ Flagged in lecture · I32
Source: Nov 10: “Maybe I'll ask this on the exam”
Prove that Max-SAT is NP-hard, in the reduction format.
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.)

✍ 10.2ILP is NP-hard reduction
Source: LP4 §10–13 + Nov 10 (“ILP solves max-SAT, which solves SAT”)
Show ILP is NP-hard via Max-SAT → ILP. Describe f and g and argue correctness briefly.
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.

x1x2x3x4¬x1¬x2¬x3¬x4f = (x1∨x2)∧(x1∨¬x3)∧(¬x2∨¬x4)∧(¬x3∨x4)clause (a∨b) gives 2 edges:¬a → b and ¬b → a8 SCCs (all single vertices),no x with x, ¬x in the same SCC⇒ satisfiablegreen = true in the assignmentfrom reverse topological order
Implication graph of the 2-SAT example from the Nov 10 board. Every arrow means “if the tail is true, the head must be true”.
How to read this figure Positive literals on the left, negations on the right, exactly as on the Nov 10 board. Each clause contributes two arrows. Green nodes are true in the assignment the SCC rule produces. Every arrow goes from a literal to one that is at least as true: no arrow runs from green to white.
Worked example (board). f = (x1∨x2) ∧ (x1∨¬x3) ∧ (¬x2∨¬x4) ∧ (¬x3∨x4). Edges: ¬x1→x2, ¬x2→x1, ¬x1→¬x3, x3→x1, x2→¬x4, x4→¬x2, x3→x4, ¬x4→¬x3. The graph is acyclic, so all 8 SCCs are singletons. Satisfiable, e.g. x1 = T, x2 = T, x3 = F, x4 = F. Unsatisfiable example: all four clauses on x1, x2 merge everything into 1 SCC.
▶ Widget: 2-SAT implication graph and its SCCs
Syntax: clauses separated by ;, each with two literals, -3 = ¬x3. Up to 6 variables. Same color = same SCC.
Traps Two edges per clause, both from a negated literal. Same SCC means same value, but different SCCs don't mean different values. The 2-SAT algorithm doesn't extend to 3-SAT, because a 3-clause isn't a single implication.
✍ 10.32-SAT on the board example calcexam-style ⚑ Flagged in lecture · I43
Source: Nov 10 board: f = (x1∨x2)∧(x1∨¬x3)∧(¬x2∨¬x4)∧(¬x3∨x4)
For f = (x1 ∨ x2) ∧ (x1 ∨ ¬x3) ∧ (¬x2 ∨ ¬x4) ∧ (¬x3 ∨ x4):
  1. List the 8 edges of the implication graph.
  2. Find the SCCs. Is f satisfiable?
  3. Give a satisfying assignment.
Show solution
  1. (x1∨x2): ¬x1→x2, ¬x2→x1. (x1∨¬x3): ¬x1→¬x3, x3→x1. (¬x2∨¬x4): x2→¬x4, x4→¬x2. (¬x3∨x4): x3→x4, ¬x4→¬x3.
  2. No cycles, so all 8 SCCs are single vertices. No x shares an SCC with ¬x, so f is satisfiable.
  3. 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.
✍ 10.4An unsatisfiable 2-SAT formula short answer ⚑ Flagged in lecture · I43
Source: Derived example (verified by the 2-SAT solver in calc.py)
Show (x1 ∨ x2) ∧ (x1 ∨ ¬x2) ∧ (¬x1 ∨ x2) ∧ (¬x1 ∨ ¬x2) is unsatisfiable using the implication graph.
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.

✍ 10.5Why SCCs decide 2-SAT proof ⚑ Flagged in lecture · I43
Source: Nov 10 lecture (implication encoding + SCC observation)
(a) Show (a ∨ b) ≡ (¬a → b) ∧ (¬b → a). (b) Show that in any satisfying assignment, all literals in one SCC have the same value. (c) Conclude: if x and ¬x share an SCC, the formula is 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.)

✍ 10.112-SAT: eliminate unit clauses (GR2 example) calcvideo ⚑ OMS video (extra) · I78
Source: OMS GR2 video, section 5 (Simplifying Input); unique satisfying assignment checked by brute force in calc.py
f = (x₃ ∨ ¬x₂) ∧ (¬x₁) ∧ (x₁ ∨ x₄) ∧ (¬x₄ ∨ x₂) ∧ (¬x₃ ∨ x₄).
  1. Apply unit-clause elimination step by step until no unit clause is left. Write each intermediate formula.
  2. Is f satisfiable? Give the assignment.
  3. Why is the formula after one elimination step satisfiable ⇔ the formula before it is?
  4. What should the algorithm do if elimination ever produces an empty clause?
Show solution
  1. 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.
  2. Yes: x₁ = F, x₂ = T, x₃ = T, x₄ = T (the only satisfying assignment).
  3. 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.
  4. 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.
✍ 10.13Why the 2-SAT assignment rule works (key fact) proofvideo ⚑ OMS video (extra) · I77
Source: OMS GR2 video, sections 11–14 (extra material); part (c)'s clause check is spelled out by me
In the implication graph of a 2-SAT formula (every clause (a ∨ b) gives edges ¬a → b and ¬b → a), for a set S of literals let S̄ = {¬ℓ : ℓ ∈ S}.
  1. Show: if there is a path α ⇝ β, then there is a path ¬β ⇝ ¬α.
  2. Show: if S is an SCC then S̄ is an SCC; and if S is a sink SCC then S̄ is a source SCC.
  3. 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
  1. Write the path as α = γ₀ → γ₁ → ⋯ → γℓ = β. Each edge γᵢ → γᵢ₊₁ comes from the clause (¬γᵢ ∨ γᵢ₊₁), which also contributes the edge ¬γᵢ₊₁ → ¬γᵢ. Following these edges backwards gives ¬β = ¬γℓ → ⋯ → ¬γ₀ = ¬α.
  2. 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.
  3. 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.

x1 ∨ x2 ∨ y1¬y1 ∨ x3 ∨ y2¬y2 ∨ x4 ∨ x5y1 / ¬y1y2 / ¬y2C = (x1 ∨ x2 ∨ x3 ∨ x4 ∨ x5) ⟶ C′ (k − 2 = 3 clauses, k − 3 = 2 new variables)If some xi is true: its clause is satisfied; set y's so the chain satisfies every other clause.If all xi are false: clause 1 forces y1 = T, clause 2 forces y2 = T, clause 3 = (¬y2) fails.
Splitting a 5-literal clause (Nov 10 board). Consecutive clauses are chained by a new variable and its negation.
How to read this figure The three boxes are the clauses of C′ for k = 5. The red links show the shared variable appearing positively in one clause and negated in the next. A true xᵢ “breaks” the chain at its box; with all xᵢ false, the chain forces y₁ = y₂ = T and the last box fails.
Worked example. C = (x1 ∨ … ∨ x5) gives C′ = (x1 ∨ x2 ∨ y1) ∧ (¬y1 ∨ x3 ∨ y2) ∧ (¬y2 ∨ x4 ∨ x5). If only x4 is true: x4 satisfies box 3; set y1 = T (box 1 ✓) and y2 = T (box 2 ✓). For k = 7: (x1 ∨ x2 ∨ y1) ∧ (¬y1 ∨ x3 ∨ y2) ∧ (¬y2 ∨ x4 ∨ y3) ∧ (¬y3 ∨ x5 ∨ y4) ∧ (¬y4 ∨ x6 ∨ x7).
Traps Prove both directions; the ⇐ direction is the one people skip. Use fresh y's for each clause. Why not 2-SAT? A middle clause needs three slots (incoming connector, an original literal, outgoing connector), and 2-SAT is in P anyway.
✍ 10.6Clause splitting: SAT → 3-SAT reductionexam-style ⚑ Flagged in lecture · I45
Source: Nov 10 board (5-literal clause) + general case
(a) Write C′ for C = (x1 ∨ x2 ∨ x3 ∨ x4 ∨ x5 ∨ x6 ∨ x7). (b) Prove C satisfiable ⇔ C′ satisfiable (for the general k-literal case). (c) How many clauses and new variables for a 10-literal clause? Why is the whole reduction polynomial?
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.

✍ 10.7Why doesn't the trick give 2-SAT? short answer ⚑ Flagged in lecture · I46
Source: Nov 10: “Why not 2SAT? I need this intermediate structure”
Why can't the same splitting idea reduce SAT to 2-SAT?
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).

✍ 10.83-SAT is NP-complete reduction
Source: Nov 10 + KT §8.4 (in-NP part)
State the two things needed to show 3-SAT is NP-complete and give each in one or two sentences.
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.

✍ 10.9k-SAT for k ≥ 3 reduction
Source: Exam-style practice (definition of k-SAT from the Nov 10 board: at most k literals per clause)
With k-SAT defined as “at most k literals per clause”, show k-SAT is NP-hard for every fixed k ≥ 3.
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.)

✍ 10.10Exact-4-SAT is NP-complete (DPV 8.8) reductionexam-stylevideo ⚑ OMS video (extra) · I76
Source: Named as practice in the OMS NP2 video (DPV 8.8); padding gadget is my construction, brute-force verified on 150 random formulas in calc.py
Exact-4-SAT: a CNF formula in which every clause has exactly 4 literals on 4 distinct variables. Find a satisfying assignment or output NO. Prove Exact-4-SAT is NP-complete.
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.

✍ 10.12Stingy SAT is NP-complete (DPV 8.3) reductionvideo ⚑ OMS video (extra) · I76
Source: Named as practice in the OMS NP2 video (DPV 8.3); solution is the standard one-line reduction
Stingy SAT: given a CNF formula φ and an integer k, find a satisfying assignment with at most k variables set to true, or output NO. Prove it is NP-complete.
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.

Recall check (answer aloud, then open)
Why is Max-SAT hard?
SAT → Max-SAT with the same formula: satisfiable ⇔ the optimum satisfies all m clauses.
When is a 2-SAT formula unsatisfiable?
Iff some x and ¬x lie in the same SCC.
A k-literal clause splits into how many clauses and new variables?
k − 2 clauses, k − 3 new variables.
2-SAT assignment rule (GR2)?
Set a sink SCC true (its complement, a source SCC, false), remove both, repeat.
Why doesn't splitting give 2-SAT?
A middle clause needs 3 slots: incoming connector, an original literal, outgoing connector.

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

After this section you can
  • 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.

x¬xy¬yzxC1 = (x)C2 = (¬x ∨ y)C3 = (¬y ∨ z ∨ x)solid = clause clique (≤ 1 vertex per clause) · red dashed = complement edge (no x with ¬x)green = independent set of size k = m = 3 → x = T, y = T, z = T satisfies all clauses
3-SAT → Independent Set for φ = (x) ∧ (¬x ∨ y) ∧ (¬y ∨ z ∨ x): one vertex per literal occurrence.
How to read this figure One cluster per clause: a single vertex for C1, an edge for C2, a triangle for C3. Solid edges stop you from taking two literals of one clause; red dashed edges stop you from taking x and ¬x. Green is an independent set of size m = 3, read off as x = y = z = T.
Worked example. φ = (x) ∧ (¬x ∨ y) ∧ (¬y ∨ z ∨ x): 6 vertices, 7 edges, k = 3. The maximum independent set has size 3 = m, e.g. x (C1), y (C2), z (C3), so φ is satisfiable with x = y = z = T. Try the unsatisfiable preset in the widget: the max independent set comes out smaller than m.
▶ Widget: 3-SAT → Independent Set gadget builder
Syntax: clauses separated by ;, literals by |, negation -. At most 3 literals per clause. Click vertices to build S.
Traps Vertices are literal occurrences, so x in C1 and x in C3 are different vertices (no edge between them). k = m, not n. Complement edges join x and ¬x in different clauses too. If a clause is satisfied twice that's fine; the set still takes one vertex per clause.
✍ 11.1Build the 3-SAT → IS graph calcexam-style ⚑ Flagged in lecture · I50
Source: Nov 12 construction applied to φ (own example: the lecture's exact formula isn't recoverable from the recording)
φ = (x) ∧ (¬x ∨ y) ∧ (¬y ∨ z ∨ x).
  1. List the vertices, the clause-clique edges, the complement edges, and k.
  2. Find an independent set of size k and the assignment it gives.
  3. Can S = {x@C1, ¬x@C2, z@C3} be chosen? Why not?
Show solution
  1. 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.
  2. 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.
  3. No: x@C1 and ¬x@C2 are joined by a complement edge (a contradiction: x and ¬x both “true”).
✍ 11.2Prove Independent Set is NP-hard (full write-up) reductionexam-style ⚑ Flagged in lecture · I47 I48 I49 I50
Source: Nov 12 lecture (three steps: transformation, ⇔, recovery) + KT 8.8
Prove Independent Set (search version: given G, k, find an independent set of size k) is NP-complete, by reducing from 3-SAT.
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 (⇒).

✍ 11.7Lecture Q&A on the IS construction short answer ⚑ Flagged in lecture · I50
Source: Nov 12 student questions
(a) “What if more than one literal in a clause is true?” (b) “What if you pick x, y and ¬y?” (c) Why k = m and not more?
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.

G: S={2,4} independent12345no edge inside SĜ: S is a clique12345Ĝ = complement edgesG: V∖S={1,3,5} covers12345every edge touches V∖S
One set, three views (Nov 12 board graph: a triangle plus two more vertices). IS in G ⇔ clique in Ĝ ⇔ complement is a vertex cover of G.
How to read this figure The same vertex set S = {2, 4} in three views. Left: no G-edge inside S, so it's independent. Middle: in Ĝ (complement edges only) the pair 2–4 is an edge, so it's a clique. Right: the other vertices {1, 3, 5} touch every G-edge, so they form a vertex cover.
Worked example. G = triangle {1,2,3} plus edges 3–4 and 4–5. Ĝ's edges: 1–4, 1–5, 2–4, 2–5, 3–5. The maximum independent set in G has size 2 (e.g. {2,4}), and the maximum clique in Ĝ also has size 2, e.g. 2–4. Same set.
Trap The complement keeps the vertices and flips only the edges. Same k on both sides.
✍ 11.3Independent set ⇔ clique in the complement reduction
Source: Nov 12 lecture (Ĝ construction)
(a) Prove: S is independent in G ⇔ S is a clique in Ĝ (same vertices, complementary edges). (b) Use it to show Clique is NP-complete. (c) Does the same idea give Clique → IS?
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 (⇐).

G: S={2,4} independent12345no edge inside SĜ: S is a clique12345Ĝ = complement edgesG: V∖S={1,3,5} covers12345every edge touches V∖S
One set, three views (Nov 12 board graph: a triangle plus two more vertices). IS in G ⇔ clique in Ĝ ⇔ complement is a vertex cover of G.
How to read this figure Compare the left and right panels: the orange vertices on the right are exactly the vertices not shaded on the left. Every edge on the right touches an orange vertex because no edge on the left joins two shaded vertices.
Worked example. In the figure, {2,4} is independent ⇔ {1,3,5} is a cover. n = 5: max independent set 2 ⇔ min cover 3.
Trap The threshold changes: independent set ≥ k ⇔ cover ≤ n − k. Maximum independent set ⇔ minimum cover.
✍ 11.4Independent set ⇔ complement is a vertex cover reductionproof ⚑ Flagged in lecture · I52 I53
Source: Nov 12 lecture + KT (8.3)–(8.5)
(a) Prove S is independent ⇔ V∖S is a vertex cover. (b) Give IS → VC and VC → IS. (c) “Is it always true that the complement of a vertex cover is an independent set?”
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.

Star (lecture's picture)cmin VC = {c}; max IS = 6 leavesPerfect matching (makes it precise)min VC = 4; a 2-approx may return all 8 (orange)complement = ∅, but max IS = 4 ⇒ no factor survives
Reductions don't preserve approximation ratios: a factor-2 vertex cover can leave nothing for independent set.
How to read this figure Left: the star the professor drew. The center alone covers every edge, and the leaves are the big independent set. Right: 4 disjoint edges. Orange marks a cover a 2-approximation is allowed to return (all 8 vertices, twice the optimum 4), whose complement is empty.
Worked example. n = 8, 4 matching edges: OPTVC = 4, allowed output 8 ≤ 2·4; complement = 0 vertices vs OPTIS = 4. The ratio is 0, so no constant factor carries over.
Trap “Exact reduction ⇒ same approximation factor” is false. A likely T/F item.
✍ 11.5Do reductions preserve approximation? short answerexam-style ⚑ Flagged in lecture · I54
Source: Nov 12 lecture (star) + the transcript editor's perfect-matching example
Vertex cover has a 2-approximation. IS → VC is an exact reduction (S ↦ V∖S). Does complementing a 2-approximate vertex cover give an approximate independent set? Prove your answer with an example.
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.

stabc123V₁V₂every edge has capacity 1; green = flow 1 = matching {a2, b1, c3}
Bipartite matching → max flow (Nov 12). Flow conservation at each u ∈ V₁ (only 1 unit can come in) stops two matching edges from sharing u.
How to read this figure Blue vertices are V₁, orange are V₂. Green arrows carry one unit of flow. Each blue vertex receives at most 1 unit from s and so can push at most 1 unit right, and each orange vertex can forward at most 1 unit to t. That's exactly the matching condition.
Worked example. Edges a1, a2, b1, c2, c3: max flow 3 via s→a→2→t, s→b→1→t, s→c→3→t, so the matching is {a2, b1, c3}.
Trap This shows matching is easy (a reduction to a problem in P). It says nothing about max-flow being hard.
✍ 11.6Bipartite matching via max flow proofexam-style ⚑ Flagged in lecture · I55
Source: Nov 12 lecture
(a) Describe the network built from a bipartite graph (V₁, V₂, E). (b) Prove: for an integral flow f, M = {(u,v) ∈ V₁×V₂ : f(u,v) = 1} is a matching. (c) What does this reduction prove about bipartite matching?
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).

abbcabcU = {ab, bc}S_a={ab} S_b={ab,bc} S_c={bc}cover {b} ⇔ set cover {S_b}vertex cover in G (orange)
Vertex Cover → Set Cover (KT 8.6): each vertex becomes the set of edges it touches.
How to read this figure Left: the graph with a vertex cover shaded. Right: the Set Cover instance that f produces. Elements are edges, and each vertex becomes the set of edges it touches. Choosing vertices and choosing sets are the same act.
Worked example. Path a–b–c: U = {ab, bc}, Sa = {ab}, Sb = {ab, bc}, Sc = {bc}. The vertex cover {b} corresponds to the set cover {Sb}. The independent set {a, c} corresponds to the disjoint sets {Sa, Sc}.
Trap KT phrases everything as decision problems and writes “Y ≤P X” for “Y reduces to X” (our Y → X). When KT proves X hard, the known hard problem Y is on the left.
✍ 11.8Vertex Cover → Set Cover (textbook only) textbookreduction
Source: KT (8.6) (Kleinberg–Tardos stands in for the missing DPV ch. 8)
Set Cover: given a universe U, subsets S₁, …, Sm and k, are there ≤ k subsets whose union is U? Show VC → Set Cover.
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).

✍ 11.9True/False: graph reductions T/F ⚑ Flagged in lecture · I41 I54
Source: Exam-style, from Nov 12 lecture
  1. Since 3-SAT → IS, the reduction IS → SAT given by Cook–Levin is just the 3-SAT → IS construction run backwards.
  2. S is a maximum independent set of G if and only if V∖S is a minimum vertex cover of G.
  3. A 2-approximation for vertex cover yields a 2-approximation for independent set via complements.
  4. In 3-SAT → IS, if the graph has an independent set of size m, the formula is satisfiable.
  5. Reducing bipartite matching to max flow shows bipartite matching is NP-hard.
  6. 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
  1. 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).
  2. True. Complements: sizes add to n, so maximizing |S| minimizes |V∖S|.
  3. False. Perfect-matching example: the 2-approximate cover can be all of V, leaving ∅.
  4. True. That's the ⇐ direction.
  5. False. It shows matching is in P (reduction TO an easy problem). Hardness would need a reduction FROM a hard problem.
  6. True. Both via the complement graph Ĝ.
Recall check (answer aloud, then open)
3-SAT → IS: vertices, edges, k?
One vertex per literal occurrence; clause cliques + complement edges; k = m.
IS ↔ VC map?
S independent ⇔ V∖S is a vertex cover; (G, k) ↦ (G, n − k).
Counterexample: VC 2-approx ⇏ IS approx?
A perfect matching: a 2-approx cover can be all of V, leaving ∅.
What does matching → max-flow prove?
Matching ∈ P (a reduction to an easy problem).

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).

After this section you can
  • 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).”

1. In NPpoly-time verifier2. Pick knownNP-hard A3. Build f:A-input → B-input4. Prove ⇔⇒ and ⇐5. Poly time+ recover with gDirection check: the arrow goes FROM the known hard problem TO the new problem B(“A → B”: an algorithm for B would solve A)
The five-part NP-completeness answer. Step 4 is where points are usually lost: prove both directions.
How to read this figure The five boxes are the paragraphs of your answer, in order. Red marks step 4, where most points are lost. The sentence underneath is the direction check to do before writing anything.
Worked example: Vertex Cover, five parts. (1) Given M, check |M| ≤ k and that every edge touches M: O(n + m). (2) Reduce IS → VC. (3) f(G, k) = (G, n − k), linear. (4) ⇒: S independent of size ≥ k ⇒ V∖S covers every edge (an edge inside S would contradict independence) and has size ≤ n − k. ⇐: M a cover of size ≤ n − k ⇒ V∖M is independent (an edge inside it would be uncovered) and has size ≥ k. (5) g(M) = V∖M, linear. So VC is NP-complete.
What loses points
  • 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).
✍ 12.1Vertex Cover is NP-complete (full template) reductionexam-style ⚑ Flagged in lecture · I47 I45
Source: Template drill (Nov 12 IS ↔ VC + KT 8.4)
Write a complete NP-completeness proof for Vertex Cover (given G, k: find a vertex cover of size ≤ k), using all five parts of the template.
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 (⇒).

✍ 12.5Spot the broken reduction short answer ⚑ Flagged in lecture · I33 I45
Source: Exam-style error analysis (common mistakes from the lecture warnings)
A student “proves” 2-SAT is NP-hard: “Take any 2-SAT formula and run the 3-SAT → IS construction; IS is NP-hard, so 2-SAT is NP-hard.” A second student proves Clique is NP-hard by showing that from a satisfying assignment of φ you get a clique in Ĝ, and stops there. What is wrong in each?
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 fromTypical gadget
Choose ≥ k objects, some pairs conflict (packing)Independent Setobjects = 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 objectsClique (or IS on Ĝ)complement graph
Boolean constraints, or nothing above fits3-SATone 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 caseidentity 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”) versionits feasibility versionsame instance; the optimum is “everything” ⇔ feasible (SAT → Max-SAT)
Same problem with an extra size condition (exactly half, even n, …)the original problempad 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, LPbuild a network or graph (matching → flow, 2-SAT → SCC)

† = textbook only (KT).

Cook–Levinsplit clausessame formulay, z varsclause cliquescomplement graphS ↦ V∖Ss,t + cap 1implication graphany problem in NPCircuit-SAT†SAT3-SATMax-SATILPIndependent SetCliqueVertex CoverSet Packing†Set Cover†Bipartite MatchingMax-Flow (P)2-SATSCCs (P)easy side:reduce TO P⇒ in PA → B: B isat least as hardsolid = shown in lecture / LP4 · dashed † = textbook only (Kleinberg–Tardos ch. 8) · green = reductions to problems in P
Map of the reductions in this unit. Arrows point from the known problem to the new one: hardness flows along the arrows.
How to read this figure When choosing a source, pick the box closest to the new problem along these arrows. The closer the shapes, the simpler f and both directions get.
Worked example: HALF-IS (independent set of exactly half the vertices). It's “IS with an extra size condition”, so reduce from IS by padding. If 2k ≤ n, add n − 2k isolated vertices (each can join any independent set). If 2k > n, add 2k − n universal vertices (no independent set of size ≥ 2 can use one). Both directions in problem 12.2, brute-force checked on 300 random graphs.
Trap Reducing from SAT/3-SAT to a graph problem from scratch is hard to invent under time pressure. First check whether IS, VC, or Clique is one small step away.
✍ 12.2HALF-IS: independent set of exactly half the vertices reductionexam-stylechallenge ⚑ Flagged in lecture · I42
Source: Exam-style practice problem (not from the materials). The padding construction is checked by brute force on 300 random graphs in calc.py
HALF-IS: given a graph G′ with an even number n′ of vertices, find an independent set of size n′/2 (or report none). Prove HALF-IS is NP-complete.
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.

✍ 12.3Set Packing is NP-hard reduction
Source: KT (8.7) (stated, proof left as an exercise there). Full solution here
Set Packing: given U, subsets S₁, …, Sm and k, find ≥ k pairwise disjoint subsets. Show IS → Set Packing.
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.

✍ 12.4Which problem should I reduce from? MCQ ⚑ Flagged in lecture · I42
Source: Decision guide practice (KT §8.10 genres + lecture reductions)
Pick the most natural source problem for each new problem and name the gadget idea.
  1. Choose ≥ k servers so that no two conflicting servers are both chosen.
  2. Choose ≤ k cameras so that every corridor (a pair of rooms) is watched by a camera in one of its rooms.
  3. Find k people who all know each other.
  4. A Boolean constraint problem with ≤ 4 literals per clause.
  5. Satisfy as many constraints as possible.
Show solution
  1. Independent Set (a packing problem with conflicts as edges): identity-like map.
  2. Vertex Cover (covering edges with vertices).
  3. Clique (or IS on Ĝ).
  4. 3-SAT (identity, since 3 ≤ 4), or SAT with clause splitting.
  5. SAT → “max” version with the same instance (Max-SAT style: satisfiable ⇔ the optimum satisfies all).
Recall check (answer aloud, then open)
The five parts?
In NP; known hard A → B; f + size; ⇒ and ⇐; recovery g + conclusion.
Most common lost points?
Wrong direction; only one direction of the ⇔; no g; forgetting “in NP”.

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 saidWhereWhy it matters
Karger is called the watermelon algorithm (“for obvious reasons”)Oct 29, Nov 3An exam may use that name
Deterministic global min-cut: max-flow for every pair (s, t), keep the bestOct 29 (student discussion)Min-cut ∈ P, unlike Max-Cut
“At random” means uniform unless stated. Weighted sampling (probability ∝ importance) is possibleNov 3Read problem statements literally
You can't “run until success” for min-cut, since minimality can't be checked. Keep the smallest of NNov 3Boosting argument structure
A Piazza question: why care about a 1-in-a-million success chance? Answer: boostingNov 3Motivation for p⁻¹ polynomial
Max-Cut is hard (“tell your friends”). Min-cut is easyNov 3T/F trap
Derandomized max-cut: different vertex orders give different cuts, all ≥ m/2Nov 3 recapT/F trap
“Maybe I'll ask this on the exam”: why Max-SAT is hardNov 10Problem 10.1
Reduction direction “is a great multiple-choice question”; shortest path → SAT, not necessarily backNov 10 Q&A§9.4
f need not be injective; f and g depend on A and BNov 10 Q&ADefinitions
The K2026 fake reduction: f must connect to gNov 10Why recovery matters
Knapsack as seen in class is not a search problem (optimality can't be verified, the DP is pseudo-polynomial)Nov 10Class definition of NP
NP-hard problems need not be search problemsNov 10NP-hard ⇏ NP
“We don't know yet” whether NP-hard problems can be solved in poly timeNov 10 Q&AWording on T/F
2-SAT assignment order: “watch the video; it's not that important for this class”Nov 10Know SCCs + the unsatisfiability test
Why the splitting trick fails for 2-SAT (needs 3 slots)Nov 10Problem 10.7
HW6 reductions are “practice for the exam”Nov 10Get HW6
Clause cliques: “don't be greedy: pick exactly one”; complement edges were the students' fix for picking y and ¬yNov 123-SAT → IS details
Proof style: contrapositive allowed; “we don't need super detailed proofs”; two sentences for poly timeNov 12How to write answers
The reverse reduction IS → SAT exists (Cook–Levin) but isn't the inverse constructionNov 12 Q&AT/F trap
IS/VC duality “would be a great final exam question” (as an LP duality question)Nov 12Final, 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 algorithmsNov 12Context only
Self-reducibility: decision ⇒ search “for your own entertainment”Nov 12Low priority
A reduction promised on the final; a practice exam will be posted before Exam 3Nov 12Scope
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 incompleteNov 3 / LP4 editorial notesSee ⚠ 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).

After this section you can
  • 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
How to use the HW5 problems Treat each original as an exam question. Give yourself about 12 minutes per part-group on paper, closed notes. Use the hint path only if you're stuck for more than 3 minutes, then compare your answer with the full solution line by line. You're not submitting HW5, so don't polish write-ups: the goal is being able to produce the key steps fast.

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α).

n verticescontractuniformlyat randomr = 2α superverticesrandom cut of the rsurvive to r: ∏(1 − 2α/t) ≥ 1/C(n, 2α) (2α integer) · then pick the right one of 2^(r−1) − 1 cuts⇒ Pr[a fixed α-small cut is output] ≥ 1/(C(n,2α)·2^(2α−1)) ⇒ #α-small cuts = O(n^(2α))
HW5 #19.2 idea: stop the watermelon at 2α supervertices, where an α-small cut still survives with probability about n^(−2α), then choose among the few remaining cuts at random.
How to read this figure Left to right is one run. Contraction proceeds normally until only r = 2α supervertices remain (third picture). There the algorithm stops and picks a random 2-coloring of the remaining supervertices, blue versus orange (last picture). The two formulas underneath are the two probability factors whose product lower-bounds “output exactly C”.
Worked example. C₁₀ with α = 2 (cuts of ≤ 4 edges). The exact count is C(10,2) + C(10,4) = 255; the bound is C(10,4)·2³ = 1,680. For the plain min-cut version, stopping at r = 4 keeps a fixed min cut alive with probability ≥ 4·3/(10·9) = 2/15.
Traps
  • 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 α.
✍ 15.1HW5 #19: Min cuts (original wording, full solution) HW5original ⚑ Past exam / HW · I66 I63
Source: homeworks/hw5.pdf, Problem 19 (verbatim)

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.

  1. 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.)
  2. 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
Stuck? Hint path (try one hint, then go back to the problem)
  1. Part 1: Karger's theorem is about each fixed min cut. Can two different cuts be returned by the same run?
  2. 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.)

✍ 15.5Re-skin of 19.1: the cycle is tight exam-styleconstruct ⚑ Past exam / HW · I65 I66
Source: Exam-style re-skin of HW5 #19.1 + tight-example part (Exam 2 pattern); counts verified by enumeration in calc.py
  1. (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.
  2. (3) Show the bound is tight: give a graph on n vertices with exactly n(n−1)/2 min cuts.
Show solution
  1. 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²).
  2. 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.)
✍ 15.6Re-skin of 19.2: α-small cuts of a cycle calcexam-style ⚑ Past exam / HW · I66
Source: Exam-style re-skin of HW5 #19.2 (counts brute-force checked in calc.py)
Take G = Cn (λ = 2) and α = 2, so α-small cuts have at most 4 edges.
  1. Count the α-small cuts exactly (in terms of n), and evaluate for n = 10.
  2. Compare with the early-stop bound C(n, 2α)·22α−1 and with n2α. Is the O(n2α) growth rate tight here?
Show solution
  1. 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.
  2. 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.)
✍ 15.7Re-skin of 19.2: stopping the watermelon early (guided) proofexam-style ⚑ Past exam / HW · I66 I61
Source: Exam-style guided version of the HW5 #19.2 technique; telescoping identity checked in calc.py
Run the contraction algorithm only until r supervertices remain (2 ≤ r ≤ n). Fix a min cut Δ of size λ.
  1. (4) Show that while Δ is intact and t supervertices remain, the next contraction avoids Δ with probability ≥ 1 − 2/t.
  2. (5) Conclude Pr[Δ survives until r supervertices remain] ≥ r(r−1)/(n(n−1)). Evaluate for n = 10, r = 4.
  3. (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. (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
  1. 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.
  2. 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)).)
  3. 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).
  4. 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.

MAX-E2SAT: all 4 sign patternsx₁ ∨ x₂x₁ ∨ ¬x₂¬x₁ ∨ x₂¬x₁ ∨ ¬x₂x=(T,T)✓✓✓✗x=(T,F)✓✓✗✓x=(F,T)✓✗✓✓x=(F,F)✗✓✓✓every row: exactly one ✗ ⇒ every assignment satisfies exactly 3/4why: a clause fails for exactlyone setting of its variables,and each setting falsifiesexactly one patternk variables, 2^k clauses ⇒always exactly 1 − 2^−k
Tight example for fair coins: use every sign pattern once. The random assignment can't beat it, because no assignment can.
How to read this figure Rows are the 4 assignments, columns the 4 clauses (all sign patterns of x₁, x₂). A ✗ marks a falsified clause. Every row has exactly one ✗, so no assignment does better or worse than 3/4. The text on the right says why that generalizes to any k.
Worked example. 20 clauses of exactly 4 literals: mean 15·20/16 = 75/4, so some assignment satisfies ≥ 19, using integrality. 5 exactly-2 clauses: ≥ ⌈3.75⌉ = 4.
Traps “Exactly k” distinct variables is what makes the expectation exact. With repeated variables or shorter clauses the clean statement fails (§6.2). “Below average ⇒ above average” needs a strict inequality somewhere: if every assignment is exactly at the mean (the tight example), there is nothing above.
✍ 15.2HW5 #20: Linearity of expectation (original wording, full solution) HW5original ⚑ Past exam / HW · I68 I65
Source: homeworks/hw5.pdf, Problem 20 (verbatim)

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.

  1. 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.
  2. 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.
  3. 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
Stuck? Hint path (try one hint, then go back to the problem)
  1. (a) One indicator per clause. A clause with 3 distinct variables fails for exactly one of its 8 settings (§6.2).
  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)
  3. (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.)

✍ 15.8Re-skin of #20: MAX-Exact-4SAT proofexam-styleconstruct ⚑ Past exam / HW · I68 I65
Source: Exam-style re-skin of HW5 #20 with k = 4 (tight example verified by brute force in calc.py)
Every clause has exactly 4 literals on 4 distinct variables.
  1. (4) Show a uniformly random assignment satisfies 15/16 of the clauses in expectation.
  2. (5) Show: if some assignment satisfies strictly fewer than 15m/16 clauses, then some assignment satisfies strictly more.
  3. (4) Construct a formula on which every assignment satisfies exactly 15/16 of the clauses.
  4. (2) A formula has m = 20 such clauses. How many clauses can you guarantee to satisfy simultaneously?
Show solution
  1. 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.
  2. 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.)
  3. 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.
  4. Some assignment achieves ≥ the mean 75/4, and counts are integers, so ≥ 19.
✍ 15.9Re-skin of #20(c): exact-2 clauses constructshort answer ⚑ Past exam / HW · I65
Source: Exam-style tight-example drill (figure in §15.2)
(a) Give a MAX-Exact-2SAT formula where every assignment satisfies exactly 3/4 of the clauses. (b) Why does no formula with exactly-2 clauses force fewer than 3/4 for every assignment? (c) m = 5 exact-2 clauses: how many can always be satisfied together?
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.

110^−110^−210^−310^−40123456789101/Mt = ln M (M = 100)rounds t (log-scale y axis): each round re-rounds the LP independently and adds what it picksPr[a fixed constraint still uncovered] ≤ e^(−t)
Rounding with repetition, on a log scale: the miss probability e^(−t) is a straight line. It crosses 1/M at t = ln M, where the expected number of uncovered constraints (M·e^(−t)) is 1.
How to read this figure The red curve is the bound on the chance that one fixed set or element is still uncovered after t rounds, e−t. The dashed horizontal line is 1/M (M = 100 constraints). Where the curve crosses it (t = ln M), the expected number of uncovered constraints, M·e−t, drops to 1. A few more rounds and the union bound makes total failure unlikely.
Worked example. Set cover with n = 100 elements: t = ⌈ln 400⌉ = 6 rounds give Pr[some element uncovered] ≤ 100·e−6 ≤ 1/4, and E[# sets] ≤ 6·OPT. For n = 1000: 9 rounds. Repeat-until-covered with n = 100: E[rounds] ≤ 6.58. Compare Exam 2 Q4: deterministic threshold rounding gave a factor k (the max frequency). Randomized rounding gives O(log n) for any instance. On the tight instance (k identical sets) the two differ by k vs about 1 (problem 15.12).
Traps
  • 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.
✍ 15.3HW5 #21: Randomized rounding for Hitting Set (original wording, full solution) HW5original ⚑ Past exam / HW · I67 I64
Source: homeworks/hw5.pdf, Problem 21 (verbatim)

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ᵢ.)

  1. Write an instance of ILP that is equivalent to Hitting-Set.
  2. 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.
  3. 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.
  4. 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.
  5. Prove this algorithm yields a ln(m)−Approximation algorithm for Hitting-Set.
Show solution
Stuck? Hint path (try one hint, then go back to the problem)
  1. (a) One 0/1 variable per element i; one covering constraint per set Sⱼ (compare HW4 #18 and Exam 2 Q4).
  2. (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.
  3. (d) After t rounds, Pr[Sⱼ still missed] ≤ e−t. Count missed sets with linearity; for E[#rounds] use E[T] = Σ Pr[T > t].
  4. (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).

✍ 15.10Predicted re-skin of #21: randomized rounding for SET COVER (guided) proofexam-style ⚑ Past exam / HW · I64 I67 I61
Source: Predicted exam version: HW5 #21 with roles swapped, the same move Exam 2 Q4 made with HW4 #18
Universe U = {1, …, n}; sets S₁, …, Sm ⊆ U with union U. Choose the fewest sets covering U.
  1. (4) Write an ILP with a variable yⱼ per set, and its LP relaxation. Why is LP* ≤ OPT?
  2. (5) Pick each set Sⱼ independently with probability y*ⱼ. For an element e in sets Sj₁, …, Sjk, show Pr[e covered] ≥ 1 − 1/e.
  3. (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. (4) Show E[# sets chosen] ≤ t·OPT.
  5. (3) Conclude: with probability ≥ 1/2 the output is a cover of size ≤ 4t·OPT = O(log n)·OPT.
Show solution
  1. 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.
  2. 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.
  3. 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).
  4. 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.
  5. 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).
✍ 15.11Re-skin of #21(d)–(e): expected number of rounds and cost proofchallenge ⚑ Past exam / HW · I67
Source: Exam-style re-skin of HW5 #21(d)–(e) on set cover; uses MU Lemma 2.9 (tail sum)
Now repeat rounds until every element is covered; let T be the number of rounds.
  1. Show Pr[T > t] ≤ n·e−t, and conclude E[T] ≤ ⌈ln n⌉ + 1/(1 − 1/e) = O(log n).
  2. Show E[total # sets picked] ≤ E[T]·LP*. (Careful: T depends on the rounds.)
Show solution
  1. 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.)
  2. 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.
✍ 15.12Tight instance for one round of rounding construct ⚑ Past exam / HW · I65
Source: Exam-style “construct an instance” (cf. Exam 2 Q4.4)
Give a set-cover instance and an optimal LP solution where one round of randomized rounding covers some element with probability exactly 1 − (1 − 1/k)k (close to 1 − 1/e for large k). Also: what does deterministic threshold rounding (pick Sⱼ iff y*ⱼ ≥ 1/k, Exam 2 Q4) pick on this instance?
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.

Prover (Raquel)knows coloring CVerifier (Brito)sees 2 colors/round1. permute colors π, commit to π(C(v)) for all v2. challenge: random edge {u,v}3. reveal π(C(u)), π(C(v)); accept if differenthonest prover: always accepted; revealed pair is uniform over distinct colors (no info about C)cheater: some edge is monochromatic ⇒ caught w.p. ≥ 1/m per round ⇒ passes all N w.p. ≤ (1 − 1/m)^N
HW5 #22's protocol: one-sided error plus independent repetition, the same boosting algebra as Karger, run in the other direction (driving a cheater's success to 0).
How to read this figure The three arrows are the three messages of one round, in order: commit (prover → verifier), challenge (verifier → prover), reveal (prover → verifier). The two lines underneath are the two guarantees. The first holds because of the prover's coin (π), the second because of the verifier's coin (the edge).
Worked example (2-coloring re-skin). m = 15 edges, ε = 10⁻³: N ≥ 15 ln 1000 → 104 rounds (exact minimum 101). m = 40, ε = 10⁻⁶: 553 rounds. With 2 colors, an honest round reveals (1,2) or (2,1), each with probability ½.
Traps
  • 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.
✍ 15.4HW5 #22: Zero-knowledge proofs and 3-coloring (original wording, full solution) HW5original ⚑ Past exam / HW · I63
Source: homeworks/hw5.pdf, Problem 22 (verbatim, protocol summarized in §15.4)

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.

  1. 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.
  2. 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.
  3. 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
Stuck? Hint path (try one hint, then go back to the problem)
  1. (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.
  2. (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.
  3. (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.

✍ 15.13Re-skin of #22: a 2-coloring protocol calcexam-style ⚑ Past exam / HW · I63
Source: Exam-style re-skin of HW5 #22 with 2 colors (numbers in calc.py)
Raquel claims G is bipartite (2-colorable) and runs the same protocol with a uniformly random permutation of 2 colors each round. Brito challenges a uniformly random edge.
  1. (4) What is the distribution of the two revealed colors in a round, for an honest prover?
  2. (4) If G is not bipartite, with m edges, bound the probability that Raquel passes all N rounds.
  3. (4) How many rounds guarantee cheating success ≤ ε? Evaluate for m = 15, ε = 10⁻³.
  4. (3) Is the overall test Las Vegas or Monte Carlo? One-sided or two-sided error?
Show solution
  1. 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”.
  2. 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.
  3. e−N/m ≤ ε ⇔ N ≥ m ln(1/ε). For m = 15, ε = 10⁻³: N = 104 (the exact minimum with (14/15)N ≤ 10⁻³ is 101).
  4. 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.
✍ 15.14What breaks the protocol? short answer ⚑ Past exam / HW · I63
Source: Exam-style conceptual variant of HW5 #22
For the 3-coloring protocol, explain what goes wrong in each modification: (a) Raquel uses the same permutation π in every round. (b) Brito asks for the color of a single random vertex instead of an edge. (c) The commitment is not binding (Raquel can change colors after seeing the challenge).
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.

Recall check (answer aloud, then open)
Why at most n(n−1)/2 min cuts?
Disjoint “returns Δᵢ” events, each with probability ≥ 2/(n(n−1)), sum to ≤ 1.
Tight example for exact-k-SAT?
All 2k sign patterns on k variables: every assignment satisfies exactly 1 − 2−k.
Set cover rounding: rounds and guarantee?
t = ⌈ln(4n)⌉ rounds, failure ≤ 1/4, E[cost] ≤ t·OPT.
Protocol rounds for cheat probability ε?
N ≥ m ln(1/ε), since (1 − 1/m)N ≤ e−N/m.

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.

Method Read each option as its own True/False question. The traps are almost always a dropped hypothesis (“X ≥ 0”, “exactly 3 distinct literals”, “in expectation”, “for a fixed cut”), a reversed direction (A → B vs B → A, LP* ≥ OPT vs ≤), or “always” where only “with high probability” holds.
Worked example (Exam 2 Q1(a), from the official solution; Unit 2 content, shown only as a format model). Of the four LP-duality statements, the correct ones were 1, 2 and 4. The false one, “every primal constraint is tight at an optimum”, was refuted with a two-constraint counterexample (x₁ ≥ 0 and x₁ ≥ −1: the second can never be tight). Model your one-liners on that.
Trap Exam 2's solutions list the full correct set for each question, but how partial selections are graded isn't documented. Treat every option as its own true/false, and when unsure, look for the counterexample first.
✍ 16.1Karger / watermelon select-all ⚑ Flagged in lecture · I17 ⚑ Past exam / HW · I60
Source: Exam 2 Q1 format (5 points)
Consider one run of the contraction (watermelon) algorithm on a connected multigraph with n vertices.

Select ALL that apply.

⃝ It always returns a cut.
⃝ It returns every fixed minimum cut with probability at least 2/(n(n−1)).
⃝ It is a Las Vegas algorithm.
⃝ Running it n² ln n times and keeping the smallest cut returns a min cut with probability ≥ 1 − 1/n.
Show solution

Correct: 1, 2, 4

  1. ✔ Two supervertices remain, which is a partition of V.
  2. ✔ The theorem, for each fixed Δ.
  3. ✘ Monte Carlo: it may return a non-minimum cut.
  4. ✔ p ≥ 2/(n(n−1)) ≥ 1/n² gives failure ≤ (1 − 1/n²)n² ln n ≤ e−ln n = 1/n.
✍ 16.2Linearity and indicators select-all ⚑ Flagged in lecture · I13 ⚑ Past exam / HW · I60 I62
Source: Exam 2 Q1 format (5 points)
Each vertex of G (m edges) independently joins A or B by a fair coin; X = number of crossing edges.

Select ALL that apply.

⃝ E[X] = m/2.
⃝ The edge indicators are mutually independent.
⃝ Pr[X ≥ m/2] > 0.
⃝ Pr[X = m/2] > 0 for every graph.
Show solution

Correct: 1, 3

  1. ✔ Linearity, each edge ½.
  2. ✘ Counterexample: a triangle never has all 3 edges crossing.
  3. ✔ Probabilistic method (MU Lemma 6.2).
  4. ✘ Counterexample: a triangle (m/2 = 1.5 is not an integer); also a single edge (X ∈ {0, 1}).
✍ 16.3MAX-SAT guarantees select-all ⚑ Flagged in lecture · I28 I31 ⚑ Past exam / HW · I60
Source: Exam 2 Q1 format (6 points)
Which statements are always true?

Select ALL that apply.

⃝ Fair coins satisfy at least half the clauses of any CNF formula in expectation.
⃝ Fair coins satisfy at least 7/8 of the clauses of any formula whose clauses have at most 3 literals, in expectation.
⃝ LP rounding satisfies at least (1 − 1/e)·OPT clauses in every run.
⃝ The better of the fair-coin and LP-rounding assignments satisfies at least ¾·OPT clauses in expectation.
Show solution

Correct: 1, 4

  1. ✔ Each nonempty clause has probability ≥ ½.
  2. ✘ Counterexample: (x) ∧ (¬x), where the expectation is 1 of 2.
  3. ✘ Only in expectation.
  4. ✔ Averaging argument with αₖ + βₖ ≥ 3/2.
✍ 16.4Reduction direction select-all ⚑ Flagged in lecture · I33 I40 ⚑ Past exam / HW · I60
Source: Exam 2 Q1 format (5 points)
Suppose problem A reduces to problem B in polynomial time.

Select ALL that apply.

⃝ If A is NP-hard, then B is NP-hard.
⃝ If B is NP-hard, then A is NP-hard.
⃝ If B ∈ P, then A ∈ P.
⃝ If A ∈ P, then B ∈ P.
Show solution

Correct: 1, 3

  1. ✔ Hardness flows forward.
  2. ✘ Counterexample: shortest path → SAT.
  3. ✔ Easiness flows backward.
  4. ✘ Counterexample: shortest path → SAT again.
✍ 16.5Classes select-all ⚑ Flagged in lecture · I38 I37 ⚑ Past exam / HW · I60
Source: Exam 2 Q1 format (6 points), course definitions
Using the course's definitions (NP = search problems with a poly-time verifier):

Select ALL that apply.

⃝ P ⊆ NP.
⃝ Every NP-hard problem is in NP.
⃝ 2-SAT is in P.
⃝ Max-SAT (find an assignment maximizing satisfied clauses) is NP-complete.
Show solution

Correct: 1, 3

  1. ✔ Solve, then verify by solving.
  2. ✘ NP-hard problems need not be search problems.
  3. ✔ SCCs of the implication graph.
  4. ✘ NP-hard, but not in NP as an optimization problem, so not NP-complete.
✍ 16.6What a valid reduction needs (select one) select-one ⚑ Flagged in lecture · I35 I36
Source: Exam 2 Q1(b) format (5 points, single answer)
Which condition is NOT required for f, g to form a reduction from A to B in this course?

Select ONE.

⃝ I has a solution ⇔ f(I) has a solution.
⃝ f and g run in polynomial time.
⃝ f is injective.
⃝ g maps a solution of f(I) to a solution of I.
Show solution

Correct: 3

  1. ✘ Required.
  2. ✘ Required.
  3. ✔ Not required (Nov 10 Q&A).
  4. ✘ Required in the search setting.
✍ 16.7Independent set / vertex cover / clique select-all ⚑ Flagged in lecture · I54 ⚑ Past exam / HW · I60
Source: Exam 2 Q1 format (6 points)
G has n vertices.

Select ALL that apply.

⃝ S is independent in G iff V∖S is a vertex cover of G.
⃝ S is independent in G iff S is a clique in the complement graph Ĝ.
⃝ Complementing a 2-approximate vertex cover always gives a 2-approximate independent set.
⃝ max |independent set| + min |vertex cover| = n.
Show solution

Correct: 1, 2, 4

  1. ✔ Both directions.
  2. ✔ Edges flipped.
  3. ✘ Counterexample: a perfect matching; the cover may be all of V.
  4. ✔ Complements: optimal sets correspond.
✍ 16.8Repetition protocols select-all ⚑ Flagged in lecture · I17 ⚑ Past exam / HW · I60
Source: Exam 2 Q1 format (6 points); HW5 #22 setting
A one-sided-error test catches a cheater with probability ≥ 1/m per round, independently over rounds.

Select ALL that apply.

⃝ After N rounds a cheater passes with probability ≤ e−N/m.
⃝ N = m ln(1/ε) rounds make cheating success ≤ ε.
⃝ An honest prover can be rejected with small probability.
⃝ Reusing the same random permutation in every round keeps the protocol zero-knowledge.
Show solution

Correct: 1, 2

  1. ✔ (1 − 1/m)N ≤ e−N/m.
  2. ✔ e−ln(1/ε) = ε.
  3. ✘ One-sided: honest provers always pass.
  4. ✘ 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.

Budget (70 min) About 25 min on Q1 (the 10-point calculation is the longest part), 10 on Q2, 15 on Q3, 17 on Q4, 3 to check reduction directions and both halves of every ⇔. If stuck on a part, assume it and move on: “you may use a stated claim from an earlier part even if you did not prove it.”
Honest grading Grade with the solutions immediately after. For each lost point, write which section of these notes would have saved it, then redo that section's ✍ problems.

17.1 Mock A

✍ M.1Mock A §1: short answer (40 points) mock Aselect-all ⚑ Flagged in lecture · I56 I10 I50 ⚑ Past exam / HW · I60 I62
Source: Mock A, exact Exam 2 layout: (a) 5 select-all, (b) 5 select-one, (c) 6 select-all, (d) 10 calculation, (e) 6 short proof, (f) 8 bounds

(a) (5 points) One run of the watermelon (contraction) algorithm on a connected multigraph with n vertices. Select ALL statements that are always true.

⃝ It is a Las Vegas algorithm.
⃝ It returns a fixed min cut with probability at least 2/(n(n−1)).
⃝ In the analysis, the probability that the k-th contraction avoids the min cut (given the past was good) is non-increasing in k (as a bound).
⃝ Keeping parallel edges is unnecessary for the analysis.

(b) (5 points) A is NP-hard, A reduces to B, and B ∈ P. What can we conclude?

⃝ Nothing: reductions say nothing about P.
⃝ P = NP.
⃝ B is NP-complete.
⃝ A is in NP.

(c) (6 points) Select ALL statements that are always true.

⃝ If E[X] = μ, then Pr[X ≥ μ] > 0.
⃝ Linearity of expectation requires independence.
⃝ Markov's inequality applies to every random variable with finite mean.
⃝ The derandomized (conditional expectations) max-cut algorithm outputs a cut with ≥ m/2 edges.

(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.)

✍ M.2Mock A §2: counting cuts (15 points) mock Aexam-style ⚑ Past exam / HW · I63 I66 I65
Source: Mock A: re-skin of HW5 #19 with a tight-example part (Exam 2 Q2 shape)
  1. (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.
  2. (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 ≥ λ.
  3. (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).

✍ M.3Mock A §3: randomized rounding for set cover (20 points) mock Aexam-style ⚑ Past exam / HW · I64 I67 I61
Source: Mock A: predicted re-skin of HW5 #21 (Exam 2 Q4 shape)
U = {1, …, n}, sets S₁, …, Sm covering U. Pick the fewest sets covering U.
  1. (4) Write an ILP and its LP relaxation.
  2. (6) Round: pick each Sⱼ independently with probability y*ⱼ. Prove that every element is covered with probability ≥ 1 − 1/e. Hint: AM–GM.
  3. (5) Repeat t = ⌈ln(4n)⌉ times and take the union. Prove that the result fails to be a cover with probability ≤ 1/4.
  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).

✍ M.4Mock A §4: a reduction (25 points) mock Areductionexam-style ⚑ Flagged in lecture · I06 I47 I45 ⚑ Past exam / HW · I64
Source: Mock A: HITTING SET is NP-complete (ties HW4 #18 / HW5 #21 to the Nov 12 reductions)
HITTING-SET (search): given subsets S₁, …, Sm ⊆ [n] and k, find H ⊆ [n] with |H| ≤ k and H ∩ Sⱼ ≠ ∅ for all j, or report none.
  1. (4) Show HITTING-SET ∈ NP.
  2. (13) Reduce VERTEX COVER to HITTING-SET and prove the ⇔.
  3. (4) Argue polynomial time and explain how to recover a vertex cover from a hitting set.
  4. (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
  1. Given H: check |H| ≤ k and that each Sⱼ meets H, in O(Σ|Sⱼ|).
  2. 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.
  3. 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 (⇒).
  4. 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

✍ N.1Mock B §1: short answer (40 points) mock Bselect-all ⚑ Flagged in lecture · I33 I43 I21 ⚑ Past exam / HW · I60 I62
Source: Mock B, exact Exam 2 layout

(a) (5 points) Select ALL statements that are always true.

⃝ Randomized Quicksort is a Las Vegas algorithm.
⃝ A Monte Carlo algorithm may return a wrong answer.
⃝ If a Monte Carlo algorithm succeeds with probability ≥ 1/n³, then O(n³ log n) independent repetitions push failure to ≤ 1/n.
⃝ If success probability is 2−n, polynomially many repetitions give success 1 − o(1).

(b) (5 points) To prove a new problem B is NP-hard using a known NP-hard problem A, you must show:

⃝ B reduces to A.
⃝ A reduces to B.
⃝ Both directions.
⃝ B ∈ NP.

(c) (6 points) Select ALL statements that are always true.

⃝ Fair coins give a 7/8-approximation in expectation for MAX-Exact-3SAT.
⃝ For a maximization ILP, the LP relaxation's optimum is ≤ the ILP optimum.
⃝ In randomized rounding for MAX-SAT, a negated literal ¬xᵢ is true with probability 1 − ŷᵢ.
⃝ Integer linear programming is NP-hard.

(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.)

✍ N.2Mock B §2: MAX-Exact-4SAT (15 points) mock Bexam-style ⚑ Past exam / HW · I68 I65
Source: Mock B: re-skin of HW5 #20 (k = 4)
  1. (4) Show a random assignment satisfies 15/16 of the clauses of a MAX-Exact-4SAT formula in expectation.
  2. (7) Show that if some assignment satisfies fewer than 15/16 of the clauses, another satisfies more.
  3. (4) Construct a formula where every assignment satisfies exactly 15/16 of the clauses.
Show solution

Full solution: problem 15.8 (a)–(c).

✍ N.3Mock B §3: a challenge protocol (20 points) mock Bexam-style ⚑ Flagged in lecture · I17 ⚑ Past exam / HW · I63
Source: Mock B: re-skin of HW5 #22 + boosting
A prover claims G (m edges) is bipartite and runs N rounds of the random-recoloring protocol with 2 colors; the verifier checks one uniformly random edge per round.
  1. (5) Distribution of the revealed colors for an honest prover, and why that reveals nothing.
  2. (6) Bound the cheating probability after N rounds when G is not bipartite.
  3. (5) Rounds needed for cheating probability ≤ 10⁻⁶ when m = 40.
  4. (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).

✍ N.4Mock B §4: Set Cover is NP-hard, then approximate it (25 points) mock Breductionexam-style ⚑ Flagged in lecture · I47 I45 ⚑ Past exam / HW · I64
Source: Mock B: VC → SET COVER (KT 8.6) + link to randomized rounding
SET-COVER (search): universe U, subsets S₁, …, Sm, integer k. Find ≤ k sets whose union is U, or report none.
  1. (4) Show SET-COVER ∈ NP.
  2. (12) Reduce VERTEX COVER to SET-COVER and prove the ⇔.
  3. (4) Polynomial time and recovery.
  4. (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
  1. Check that the chosen sets number ≤ k and that their union is U: polynomial.
  2. 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.
  3. |U| = m, n sets, total size 2m: linear. g maps chosen sets to their vertices. A “none” answer is correct by (⇒).
  4. 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.