4.6.24 · D3Theory of Computation

Worked examples — P vs NP — statement, why it matters

2,036 words9 min readBack to topic

This page is the "try every case" companion to the P vs NP topic note. We will not add new theory — we will take the ideas (, , verifier, certificate, NP-complete) and push them through every kind of situation you can meet, including the weird edge cases and the exam trick questions.

Before we start, one reminder in plain words so nothing is used before it's built:

Recall The four words we keep using

Decision problem ::: a question with a yes / no answer. ::: problems a computer can solve (find the yes/no) in time — polynomial, "fast". ::: problems where, if the answer is yes, someone can hand you a short certificate and you can check it's really yes in polynomial time. Certificate (witness) ::: the short "hint" (like a filled-in Sudoku) that a checker verifies.


The scenario matrix

Think of every P vs NP question as landing in exactly one of these cells. Our examples below will visit each one.

Cell Situation The trap it hides
C1 Problem is in P (solve fast) Beginners forget it's also in NP
C2 Problem is in NP but its P-status is open / NP-complete "verifiable" ≠ "solvable"
C3 NP-hard but NOT in NP (degenerate / undecidable) the name "NP-hard" fools you
C4 The "no" answer — can we certify a no? NP only promises a yes-certificate
C5 Zero / degenerate input (, empty set, trivial target) edge cases break naive reasoning
C6 Limiting behaviour: exponential vs polynomial as "finite" is mistaken for "fast"
C7 Word problem (real world) translating English → decision problem
C8 Exam twist: "one NP-complete problem is in P" the collapse

Now, one figure to fix the whole landscape in your eyes before the examples.

Figure — P vs NP — statement, why it matters

Example 1 — Cell C1 (a problem that IS in P, and therefore in NP)


Example 2 — Cell C2 (in , P-status open: Subset-Sum)


Example 3 — Cell C4 (certifying a "NO" answer — the subtle case)


Example 4 — Cell C6 (limiting behaviour: why "finite" ≠ "fast")

Figure — P vs NP — statement, why it matters

Example 5 — Cell C5 (zero / degenerate inputs)


Example 6 — Cell C3 (NP-hard but NOT in NP — the Halting Problem)


Example 7 — Cell C7 (real-world word problem)


Example 8 — Cell C8 (exam twist: the collapse)

Figure — P vs NP — statement, why it matters

Connections