The 20 definitions you must write precisely
- f = O(g): ∃ c, n₀ > 0 : f(n) ≤ c·g(n) ∀ n ≥ n₀ (Ω: ≥; Θ: both).
- Time/space complexity: worst-case steps / cells used as a function of input size n.
- Decision problem / language: YES/NO question; L = set of YES instances.
- P: decidable deterministically in poly time.
- NP: ∃ poly-time verifier with poly-size certificates (equivalently: NTM poly time).
- co-NP: complements of NP languages (short NO-certificates).
- A ≤ₚ B: poly-time f with x ∈ A ⟺ f(x) ∈ B.
- NP-hard: every NP problem ≤ₚ it. NP-complete: NP-hard ∧ ∈ NP.
- Turing machine: (Q, Σ, Γ, δ, q₀, q_acc, q_rej); configuration = state+tape+head.
- NTM: δ maps to a set of moves; accepts iff some branch accepts.
- Cook–Levin: SAT is NP-complete (tableau + 2×3 windows).
- 3-SAT: CNF, exactly 3 literals/clause; NP-complete via clause splitting.
- CLIQUE: k pairwise-adjacent vertices; NP-complete from 3-SAT (literal vertices, k = m).
- PSPACE: poly space, any time; = NPSPACE (Savitch: NSPACE(f) ⊆ SPACE(f²)).
- TQBF: truth of fully quantified Boolean formula — PSPACE-complete; quantifiers = game moves.
- EXP: time 2^poly; P ⊊ EXP (time hierarchy) — unconditional separations exist.
- ρ-approximation: poly-time, always within factor ρ of OPT (proved!).
- PTAS / FPTAS: (1+ε)-approx in poly time for each fixed ε / poly in n and 1/ε.
- Interactive proof / IP: prover-verifier dialogue, randomised verifier, completeness + soundness; IP = PSPACE (Shamir).
- Pseudo-polynomial / weak vs strong NPC: poly in numeric value (SUBSET-SUM DP) vs hard even with small numbers (TSP).
The relationships table
L ⊆ NL ⊆ P ⊆ NP ⊆ PSPACE = NPSPACE = IP ⊆ EXP ⊆ NEXP
proved strict: P ≠ EXP, NL ≠ PSPACE everything else: OPEN
P ⊆ NP ∩ co-NP; NP =? co-NP open; BQP ⊉ NP (conjectured)
The reduction map to reproduce on demand
every NP problem ──Cook–Levin──▶ SAT ──split──▶ 3-SAT
3-SAT ──▶ CLIQUE ──complement──▶ IND-SET ──V∖S──▶ VERTEX-COVER
3-SAT ──▶ SUBSET-SUM (digit columns) 3-SAT ──▶ 3-COLOURING (palette+OR)
3-SAT ──▶ HAM-CYCLE ──weights 1/2──▶ TSP(decision)
Standard exam questions & answer skeletons
Q: "Prove X is NP-complete." — 4 steps: ① certificate ⟹ X ∈ NP; ② choose source A (say why it fits); ③ construction f + "computable in poly time"; ④ iff both directions, decoding even unintended solutions. Never reduce X → A!
Q: "Show sorting needs Ω(n log n) comparisons." — decision tree, ≥ n! leaves, height ≥ log₂(n!) = Θ(n log n) by Stirling.
Q: "State and sketch Cook–Levin." — SAT ∈ NP (assignment certificate); hardness: t×t tableau of NTM configurations; variables x[i,j,s]; φ_cell ∧ φ_start ∧ φ_move (2×3 legal windows — constant list since machine is fixed) ∧ φ_accept; poly size; satisfiable ⟺ accepting branch exists.
Q: "Explain consequences of P = NP." — crypto collapses (key recovery is NP-search), optimisation & proof-finding automated, learning optimal; caveat: needs small exponents to matter practically.
Q: "2-approximation for vertex cover + proof." — greedy matching, both endpoints; OPT ≥ |M| (must hit each matched edge), ALG = 2|M| ≤ 2·OPT.
Q: "Why doesn't a fast SAT solver in industry contradict NP-completeness?" — NP-completeness is worst-case; industrial instances have structure (clause learning exploits it); hard families still force exponential behaviour.
Last-minute traps
- NP = nondeterministic-polynomial, not "non-polynomial"; P ⊆ NP always.
- NP-hard ≠ NP-complete (hard may lie outside NP: TSP-optimisation, halting).
- Reduction direction: hardness flows from known to new.
- "Polynomial in the value" ≠ "polynomial in the input size" (SUBSET-SUM!).
- Savitch kills the space version of P vs NP — say "PSPACE = NPSPACE" with confidence, and remember the time version is the open one.
The formula & fact sheet (one glance before entering the hall)
Asymptotics: log n ≺ n^ε ≺ nᵏ ≺ cⁿ ≺ n! (each strictly slower than the next)
Sorting: comparison lower bound Θ(n log n); merge/heap sort achieve it
Searching: binary search Θ(log n) — optimal among comparison algorithms
Graphs: BFS/DFS O(n+m); Dijkstra O((n+m) log n); Bellman–Ford O(nm); Floyd–Warshall O(n³)
Simulations: multi-tape → 1-tape: t → t²; NTM → DTM: t → 2^O(t); Savitch: f → f²
Counting: 2^(2^n) Boolean functions on n inputs; almost all need circuits ≈ 2ⁿ/n
Approx: vertex cover 2; metric TSP 3/2 (Christofides) or 2 (double-MST);
set cover ln n; knapsack FPTAS (1−ε in time poly(n, 1/ε))
Master class table (reproduce from memory — it answers half the short questions)
| Class | Defining resource | Flagship / complete problem | Status |
|---|---|---|---|
| L | deterministic O(log n) space | undirected reachability lives here (Reingold) | L ⊆ P; equality open |
| NL | non-deterministic log space | directed s–t reachability (NL-complete) | NL = co-NL proved |
| P | deterministic polynomial time | shortest path, 2-SAT, primality | the "tractable" base camp |
| NP | polynomial-time verifiable | SAT, 3-SAT, CLIQUE, VC, HAM-CYCLE, SUBSET-SUM | P =? NP open |
| co-NP | short NO-certificates | TAUTOLOGY, UNSAT | NP =? co-NP open |
| PSPACE | polynomial space | TQBF, generalised game strategies | = NPSPACE (Savitch); = IP (Shamir) |
| EXP | 2^poly time | generalised chess (EXP-complete) | P ⊊ EXP proved |
The 12 must-do questions (write them, don't read them)
- From the definition, prove 7n³ + 3n = O(n³) and show n³ ≠ O(n²). (Unit 1, 4–5 marks)
- Define P, NP, NP-hard, NP-complete; draw the containment diagram; one example each. (Unit 1, 6–8)
- Prove: if any NP-complete problem is in P, then P = NP. (Unit 1, 4)
- Define ≤ₚ; prove transitivity; explain the direction trap with an example. (Unit 1, 5)
- Define a TM as a 7-tuple; design and trace one for {0ⁿ1ⁿ}; state its time and space. (Unit 2, 6–8)
- Define NTM acceptance; prove verifier-NP = NTM-NP (choice string = certificate). (Unit 2, 6)
- State Savitch's theorem; sketch the midpoint recursion; conclude PSPACE = NPSPACE. (Units 2/4, 5)
- State Cook–Levin; reproduce the seven-line tableau proof skeleton. (Unit 3, 8–10)
- Prove 3-SAT NP-complete via clause splitting — both directions of the chain argument. (Unit 3, 6–8)
- Prove CLIQUE NP-complete from 3-SAT — full gadget, both directions, polynomiality. (Unit 3, 8–10)
- Prove an unseen problem NP-complete by the 4-step recipe — practise on DOUBLE-SAT and PARTITION until automatic. (Unit 3, 8–10)
- Vertex-cover 2-approximation with proof, plus short notes on PTAS/FPTAS, IP = PSPACE, and consequences of P = NP. (Unit 4, 5–8 each)
Common mistakes that cost real marks
| Mistake | Fix |
|---|---|
| Defining O(·) without n₀, or hand-waving "for large n" | always produce explicit c and n₀ |
| Writing "NP = non-polynomial" anywhere | nondeterministic polynomial; state P ⊆ NP early |
| NP-completeness proof missing the "∈ NP" half | the certificate sentence is two free marks — write it first |
| Reduction written from NEW to KNOWN | hardness flows FROM known TO new; check before building gadgets |
| Arguing only one direction of the iff | the ⟸ direction (decoding arbitrary solutions) is where examiners look hardest |
| "TSP is NP-complete" without saying decision version | optimisation TSP is NP-hard; the decision version is NP-complete |
| Claiming Savitch resolves P vs NP | Savitch is about SPACE; the time question remains open |
| "Quantum computers solve NP-complete problems" | conjectured false — Grover gives only a quadratic speed-up |
| Confusing pseudo-polynomial with polynomial | O(n·T) is exponential in the bit-length of T (SUBSET-SUM) |
The night before: a 60-minute pass
- (15 min) Write the 20 definitions from memory; check against the list at the top of this lesson.
- (10 min) Draw the class-containment map and the reduction map blind, then compare.
- (20 min) Write the Cook–Levin skeleton and one full gadget reduction (CLIQUE or PARTITION) on paper.
- (10 min) Recite the four coping strategies for NP-hardness and the vertex-cover ratio-2 proof.
- (5 min) Read the mistakes table once. Then sleep — pattern-matching reductions needs a fresh head more than one extra hour of notes.
In the hall: structuring answers under time pressure
- Definitions first, displayed one per line — they are scanned for keywords.
- For reductions, write the recipe's four step names as headers, then fill them in: partial credit attaches to named steps even if the gadget wobbles.
- For "short notes", prefer the topics this course tabulated (complexity classes, approximation spectrum, barriers, weak vs strong NPC) — structured answers read as mastery.
- Two unbreakable rules: never leave the membership-in-NP sentence unwritten, and never reduce in the wrong direction. Those alone are worth several marks per paper.