VIEW THIS AS

Auto mode follows the Route Engine until you choose a viewpoint.

YOU ARE HERE

ROUTE CHECK

CONNECTED TO

WHAT NEXT

Use the canonical route for this room, or HELP if you are unsure.

The Gold Standard of Computational Complexity Theory

Computational complexity theory studies the resources required to solve precisely defined computational problems as their inputs grow. It asks how much time, memory or other resources an algorithm uses, and what limits apply to every possible algorithm in a specified model. Its practical value is learning to distinguish a slow implementation, a poor algorithm, a difficult problem family and a task whose requirements need to change.

The gold standard is an argument whose assumptions can be checked: state the input encoding, define the required answer, identify the resource being counted, and separate what an algorithm achieves from what has been proved unavoidable. This guide develops that discipline through original small examples of searching, graph selection, certificates, reductions and subset-sum tables. It does not claim to resolve P versus NP or to predict a production solver’s runtime from a complexity label alone.

Use the Gold Standard collection and How X Works hub to find related subjects. Descriptive Complexity approaches computational classes through logic. The Education parent guide supplies the learning criterion here: can you still reason correctly when the input, representation or requested output changes?

CHAPTER 1 OF 14 · Define the computational task

1. Define the task before measuring its difficulty

Back to contents

One instance is not a problem family

Suppose four jobs have processing times 2, 3, 5 and 7 units. Asking whether some of these jobs total exactly 10 units is one instance. Asking the same question for arbitrary finite lists of nonnegative integer durations and arbitrary nonnegative integer targets defines a version of the subset-sum problem. The first question has a small answer: select the jobs of lengths 3 and 7, or those of lengths 2, 3 and 5.

Complexity theory concerns how a method behaves across a growing family of inputs. A clever observation about these four values does not establish a general efficient algorithm. Equally, a difficult example on one computer does not establish a mathematical lower bound. Keeping those statements apart prevents much confusion when a demonstration is described as a breakthrough.

Specify whether each job may be selected once or repeatedly. Our version permits each listed position at most once. Two jobs with the same duration remain two different available jobs. This detail matters because turning the list into a set of distinct values would silently discard multiplicity. The input contract is part of the mathematics, not administrative decoration.

Decision, search and optimisation ask different questions

A decision task asks whether a valid choice exists. A search task asks for such a choice. An optimisation task asks for the best choice according to an objective, such as the greatest total not exceeding a capacity. Counting asks how many valid choices exist. They share data and may have useful relationships, but an algorithm for one should not be advertised as solving all four without an argument.

In the four-job example, “yes” is a complete decision answer and an incomplete search answer. Returning the subset 3 and 7 solves search but does not count all solutions. A reader should be able to inspect the output and identify which promise has actually been met. This is also how to diagnose a software requirement that uses the vague phrase “solve the schedule.”

Contents · Next chapter

CHAPTER 2 OF 14 · Define the computational task

2. Measure input length rather than numerical magnitude

Back to contents

The representation changes the scale

An integer can be written in binary using far fewer symbols than its value. The positive number 1,024 requires 11 binary digits: a one followed by ten zeros. A procedure that performs 1,024 iterations is therefore not performing one iteration per input digit. With values near powers of two, the numerical magnitude grows exponentially with the digit count.

For a list of integers, input length includes the digits needed for every value, the target and enough structure to distinguish entries. If there are m values, it is often convenient to analyse a method in terms of both m and target T. But a bound involving T does not automatically mean polynomial time in the binary input length. We will return to this distinction when building a subset-sum table.

Unary encoding writes a value using a repeated symbol. An algorithm taking time proportional to that value may be polynomial in the unary representation while failing to be polynomial in the binary representation. This is not a contradiction. The input supplied to the algorithm has changed, sometimes dramatically. Always ask what counts as one symbol before comparing complexity claims.

Large arithmetic is not automatically one operation

In an introductory analysis, we may count an addition or comparison as one operation when numbers fit an agreed machine word. If the computation constructs integers with millions of digits, that assumption becomes inappropriate. Reading, adding, multiplying and storing those integers consume resources that depend on their representation length.

Record the model beside the calculation. For the small examples in this guide, ordinary arithmetic is exact and small enough to inspect directly. For general bit-complexity claims, include the cost of manipulating large numbers. A calculation that conceals a huge object inside a supposedly constant-time operation can make an inefficient method look misleadingly efficient.

Previous chapter · Contents · Next chapter

CHAPTER 3 OF 14 · Define the computational task

3. Separate an upper bound from a lower bound

Back to contents

What a working algorithm establishes

Consider an unsorted array of n entries and a target value. Scanning entries from left to right until finding the target, or reaching the end, makes at most n equality checks. This gives an upper bound for that algorithm. In the worst case the target is absent, or appears only at the final position, so this particular method performs n checks.

Under an exact query model with an arbitrary unsorted array and no previous index, an algorithm cannot generally certify absence while leaving a position unread. An adversary could place the target in that unread position without changing anything the algorithm has observed. That argument supplies a lower bound of n inspections in the worst case for this model and task.

Notice the qualifications. A sorted array supports different methods. An existing index is additional information. A promise about the distribution of entries changes what can be inferred. A probabilistic answer that permits error is not the same contract as an exact answer. Lower bounds must identify the conditions under which alternative methods are being ruled out.

Why a failed search proves little

If a program examines a million candidate schedules and finds none, it has proved that those candidates fail. Unless they exhaust the permitted space or the method supplies a valid exclusion argument for the rest, it has not proved that no schedule exists. “No answer found” and “no answer exists” are different outputs and should remain different in the interface.

Similarly, counting all possible candidates gives the cost of exhaustive enumeration, not a lower bound on every algorithm. Sorting does not normally enumerate every permutation before selecting the sorted one. A problem may have an enormous space of potential answers and still admit a method that exploits structure. The useful next question is what structure the current method ignores.

Previous chapter · Contents · Next chapter

CHAPTER 4 OF 14 · Measure and verify

4. Read growth rates without pretending they are stopwatch predictions

Back to contents

A controlled comparison

Imagine three methods with deliberately simplified operation counts n squared, n cubed and 2 to the power n. At n = 20 their counts are 400, 8,000 and 1,048,576. At n = 40 they are 1,600, 64,000 and 1,099,511,627,776. Doubling the input multiplies these counts by 4, 8 and 1,048,576 respectively.

The comparison explains why growth rate matters. It does not establish how many seconds any real program takes. An “operation” could be a memory access, a complicated compatibility test or a large-integer calculation. Different hardware, data layouts, cache behaviour and implementation overhead can change the measured result. State the operation being counted before assigning a throughput.

As a hypothetical calculation only, a device performing exactly one million of these operations per second would take about 1,099,512 seconds for 2 to the power 40 operations, or roughly 12.7 days. This assumes constant throughput and no other work. It is an arithmetic illustration, not a performance forecast for an actual solver.

Big O is a bound, not an equality

Saying a runtime is O(n squared) means it is eventually bounded above by a constant multiple of n squared. It does not say the runtime equals n squared, and it does not guarantee the bound is tight. A linear-time procedure also satisfies an O(n squared) upper bound, although that description throws away useful information.

When two methods are being compared for a real workload, inspect both asymptotic behaviour and the relevant finite range. A method with a large setup cost may lose on small inputs and win later. A polynomial with a high degree can remain unusable at practical sizes. Conversely, an exponential algorithm can be entirely reasonable for a small parameter that is genuinely bounded.

Previous chapter · Contents · Next chapter

CHAPTER 5 OF 14 · Measure and verify

5. Understand P and NP through explicit promises

Back to contents

What membership means

P contains decision problems solvable by a deterministic algorithm within a polynomial bound on input length. NP can be described through polynomial-length certificates checked in polynomial time: a yes-instance has an acceptable certificate, and a no-instance has none. The verifier must be a fixed algorithm with the promised bounds across the whole problem family.

For subset sum, a certificate can be a bit vector with one bit for each list position. A one means select that item. The verifier checks the format, adds the selected nonnegative integers and compares the result with the target. The certificate does not need to contain a transcript of an enormous search. It only needs to support the particular yes-answer being checked.

Every problem in P is also in NP: a verifier can solve it directly and ignore any certificate. NP therefore does not mean “not polynomial.” The name refers to nondeterministic polynomial time. Using NP as a synonym for “impossible” confuses a classification with an unproved assumption about difficulty.

The unresolved boundary

As checked on 5 November 2026, the Clay Mathematics Institute lists P versus NP as unsolved. Stephen Cook’s official problem description gives the formal setting. The question is whether the two classes are equal, not whether every verification task has an obvious practical search method today.

Even a hypothetical equality would not mean that every existing program becomes fast, that constants disappear or that an implementation is immediately available. Conversely, believing the classes differ is not a proof that a particular instance will take a long time. Keep the general theorem, the particular algorithm and the actual workload as three separate levels of discussion.

Previous chapter · Contents · Next chapter

CHAPTER 6 OF 14 · Measure and verify

6. Check a graph certificate completely

Back to contents

A small selection problem

Let a simple undirected graph have vertices a, b, c, d and e, with edges ab, bc, cd, de and ea. This is a five-cycle. An independent set is a collection of vertices with no edge joining two selected vertices. Ask whether an independent set of size at least two exists. The certificate {a,c} works because ac is not an edge.

A complete verifier checks that every named vertex belongs to the graph, that the list has no repeated vertex, that its size reaches the required threshold, and that no edge has both endpoints selected. Merely counting two names is inadequate: {a,a} names one vertex twice. Checking only that ac is absent is also inadequate if the certificate contains a third vertex whose conflicts were ignored.

With a membership flag for each vertex, the verifier can scan the edge list and reject any edge with two selected endpoints. The usual graph-operation accounting gives linear work in the number of vertices plus edges, with appropriate representation assumptions. The simple mechanism is more useful than memorising a complexity label without knowing what the checker does.

A no-answer needs its own justification

The five-cycle has no independent set of size three. One way to see this is that every selected vertex must be followed around the cycle by an unselected vertex. Three selected vertices would therefore require at least three unselected vertices, giving at least six positions, while the cycle has only five.

This is a short mathematical argument for this graph family, not a claim that every no-instance of every NP problem has an equally convenient certificate. A failed proposed independent set only disproves that proposal. The graph connects to practical conflict modelling in Graph Colouring, Exam Conflicts and Timetable Planning, where the precise interpretation of an edge matters before any solver is chosen.

Previous chapter · Contents · Next chapter

CHAPTER 7 OF 14 · Reduce and construct

7. Follow a reduction in the correct direction

Back to contents

Translate one question into another

A polynomial-time many-one reduction from decision problem A to decision problem B maps each input x of A to an input f(x) of B, in polynomial time, so that x is a yes-instance exactly when f(x) is a yes-instance. A solver for B can then answer A by applying the translation first. The direction is A to B because B is the service we would use to solve A.

For a graph G with n vertices, a set S is independent exactly when its complement V minus S is a vertex cover. A vertex cover touches every edge. If S contains no internal edge, every edge has an endpoint outside S, so the complement covers it. Conversely, if the complement covers every edge, no edge can lie wholly inside S.

Thus asking for an independent set of size at least k translates into asking for a vertex cover of size at most n minus k on the same graph. The transformation changes the threshold and keeps the graph. It is efficient, preserves yes and no answers, and includes the complementary size inequalities rather than treating them as interchangeable equalities.

Work both directions on the five-cycle

For k = 2, the threshold for vertex cover is 5 minus 2 = 3. The independent set {a,c} corresponds to cover {b,d,e}. Check all five edges: ab touches b; bc touches b; cd touches d; de touches d and e; ea touches e. No edge is missed.

For k = 3, the translated threshold is two. The absence of an independent set of size three corresponds to the absence of a vertex cover of size two. Showing one successful example checks arithmetic, but the earlier complement argument is what validates the reduction for every graph. MIT’s lecture on reductions and NP-completeness provides the formal continuation.

Previous chapter · Contents · Next chapter

CHAPTER 8 OF 14 · Reduce and construct

8. Interpret NP-hardness and NP-completeness carefully

Back to contents

Two obligations, not one impressive label

Under polynomial-time many-one reductions, an NP-hard problem is one to which every problem in NP reduces. An NP-complete problem is both NP-hard and in NP. Proving completeness therefore requires two different arguments: an efficient verifier for the target problem, and an appropriate reduction establishing hardness.

To prove a new target hard, reduce an established hard problem to the target. Reducing the target to an easy problem would instead provide a route to solving the target efficiently. Reversing this arrow is a common error because the diagrams can look superficially similar while expressing opposite uses of the supposed solver.

The graph equivalence in the previous chapter explains a valid transformation. By itself it is not a complete independent proof that either problem is NP-complete; a hardness starting point still has to be supplied. A learning article should make that dependency explicit instead of allowing a small example to stand in for a theorem about all NP problems.

Hardness belongs to a defined family

NP-hardness does not say every instance is hard. Some instances have obvious witnesses; some have strong exploitable structure; some are small. A practical solver may handle many examples while a worst-case classification remains unchanged. Equally, a solver that performs well on a convenient benchmark does not refute a worst-case hardness result.

The article on Jigsaw Puzzles, Edge Matching and Search Complexity illustrates why the formal variant matters. Restrictions on rotations, shapes and compatibility rules define different computational tasks. A theorem about one generalised puzzle family should not become a claim about the time any person needs for one ordinary picture puzzle.

Previous chapter · Contents · Next chapter

CHAPTER 9 OF 14 · Reduce and construct

9. Build a dynamic programme and inspect its hidden parameter

Back to contents

Reachable totals, one item at a time

Return to values 2, 3, 5 and 7 with target 10. Start with reachable set {0}, representing the empty selection. After processing 2, the reachable totals are {0,2}. After processing 3 they are {0,2,3,5}. At each step, keep the old totals and add the new item once to each old total, discarding sums above the target because all values are nonnegative.

After processing 5 the totals are {0,2,3,5,7,8,10}. After processing 7 they are {0,2,3,5,7,8,9,10}. Since 10 is present, the decision answer is yes. The update must use the preceding stage, not repeatedly reuse newly generated totals during the same item’s update. Otherwise the method may accidentally solve a version allowing unlimited copies.

An invariant explains correctness: after i items, the stored totals are exactly the sums at most T obtainable from subsets of those i positions. Any such subset either excludes item i, leaving an old total, or includes it, giving an old total plus its value. Conversely, each generated total corresponds to one of these legitimate choices. This proves the update rather than relying only on a successful example.

Why pseudo-polynomial matters

A Boolean table has m stages and T plus one possible totals per stage. A straightforward implementation takes O(mT) basic table work and can store only two rows, or one carefully updated row, for O(T) Boolean storage. These statements describe the conventional table-operation model; reading and manipulating encoded numbers also has a cost.

The dependence on T is the warning. When T is binary-encoded, its magnitude can be exponential in its digit length. The table is therefore called pseudo-polynomial, not polynomial in general binary input length. James Aspnes’s Yale notes place subset sum in the reduction framework; the table and invariant above show directly why a seemingly efficient numerical recurrence does not settle P versus NP.

Previous chapter · Contents · Next chapter

CHAPTER 10 OF 14 · Apply and transfer

10. Recover an answer and account for memory

Back to contents

A yes-bit does not identify the selected jobs

The Boolean table tells us whether a sum is reachable. To return an actual subset, retain predecessor information or reconstruct choices using additional computations. In a full staged table, begin at the final stage and target. If the target was reachable without the last item, skip it. Otherwise include that item, subtract its value and move to the preceding stage.

For target 10, the staged example can skip 7 because 10 was already reachable using the first three items. It then includes 5, leaving target 5. At the preceding stage, 5 requires including 3, leaving 2, and then including 2. The recovered subset is {2,3,5}. Another valid method might return {3,7}. Neither is wrong unless the specification demands an additional preference.

Discarding rows saves memory, but can make straightforward reconstruction unavailable. That does not make reconstruction impossible; it changes the design trade-off. One may retain selected predecessor data, recompute information, or use a different algorithm. Report memory usage alongside runtime and distinguish the decision-only implementation from a search implementation that stores additional evidence.

Output itself has a cost

If the task changes to listing every valid solution, the output may be large. Even a clever algorithm must spend time emitting what the user requested under an ordinary explicit-output model. This is why an enumeration claim should specify whether runtime is measured before the first answer, between answers or until the entire list is complete.

In our small subset-sum instance, two selections total 10. With many zero-valued items, the number of distinct subsets representing the same numerical sum can multiply rapidly, because including or excluding each zero changes the selected positions without changing the total. A Boolean reachability table intentionally collapses those alternatives. It cannot be repurposed as a counting table without modifying its meaning.

Previous chapter · Contents · Next chapter

CHAPTER 11 OF 14 · Apply and transfer

11. Choose a response when the general problem is difficult

Back to contents

Change the method before abandoning the task

Start by checking whether the actual instances have structure: a small target, few conflicts, bounded group sizes or repeated subproblems. An algorithm that is unsuitable for the unrestricted family may work well on a justified restricted family. Document the restriction and validate it on incoming data. A promise that is only usually true cannot silently support an exact guarantee.

Next ask whether the user requires an optimum, any feasible solution, or a solution with a specified quality bound. These are different contracts. A heuristic can be useful even without a worst-case guarantee, provided its output is checked and its limitations are visible. An approximation guarantee is stronger than saying a result “looks close”; it needs a defined objective and a proved relationship to the optimum.

For the nonnegative subset-sum example, changing exact equality to “as large as possible without exceeding 10” happens to leave an optimum of 10. If the target changes to 6, the best reachable total is 5 and the exact decision answer is no. A programme returning 5 should not label the equality problem solved. It has answered the altered optimisation question.

Set honest stopping conditions

A time-limited search should report the best verified solution found, any valid lower or upper bounds it has established, and whether optimality or infeasibility has been proved. A timeout is not an infeasibility certificate. It is also not a reason to discard a useful feasible answer when the user’s contract permits one.

For planning, separate the cost of producing a candidate from the cost of checking it. A fast independent checker can protect against implementation errors in a complicated search procedure. It cannot prove that the search considered every possibility, but it can establish that a returned schedule satisfies the encoded constraints. That is a useful and precisely limited form of confidence.

Previous chapter · Contents · Next chapter

CHAPTER 12 OF 14 · Apply and transfer

12. Test transfer by changing the assumptions

Back to contents

Exercise: permit repeated use of each duration

Keep durations 2, 3, 5 and 7, but allow unlimited repetitions. Ask whether total 6 is attainable. In the original once-per-position problem it is not: the reachable totals at or below 6 are 0, 2, 3 and 5. With repetition permitted, 3 plus 3 or 2 plus 2 plus 2 reaches 6. The correct answer changes because the admissible selections changed.

Explain why a forward update of a one-dimensional table can now be appropriate while it was dangerous for the original contract. Values discovered earlier in the same pass can represent further uses of the current item. The update direction is therefore a mathematical design choice tied to the permitted multiplicity, not merely a coding style preference.

Exercise: add one conflict edge

Take the five-cycle and add edge ac. The earlier certificate {a,c} is now invalid. Does that mean there is no independent pair? No: {a,d} remains independent. Rechecking one stored answer and solving the entire changed instance are separate tasks. A dependable workflow first invalidates the obsolete certificate, then searches or reasons about the revised graph.

Exercise: scale every numerical value

Multiply all four durations and the target by 1,000. The existence of a solution is unchanged: a selected sum equals 10 exactly when its scaled sum equals 10,000. But a direct table indexed by every integer up to the target becomes much larger. Dividing by the common factor restores the original instance in this constructed example.

This exercise shows why preprocessing can matter without changing the general worst-case classification. It also shows why benchmarking only scaled copies of one easy structure is weak evidence for broad performance. A useful test set changes structural properties as well as sizes and includes instances whose answers are no, so that a solver cannot pass merely by finding convenient witnesses.

Previous chapter · Contents · Next chapter

CHAPTER 13 OF 14 · Diagnose and learn

13. Diagnose common misunderstandings

Back to contents

Does exponential brute force prove exponential necessity?

No. It proves a cost for that enumeration strategy. To establish a lower bound, specify the computational model and give an argument applying to every allowed algorithm. The unsorted-search adversary argument in Chapter 3 is a small example of such reasoning. Counting candidates alone is not that argument.

Does NP mean that answers cannot be found quickly?

No. NP includes P. It concerns polynomially checkable certificates for yes-instances, or the equivalent nondeterministic formulation. A particular NP problem may have a deterministic polynomial-time algorithm. A particular instance of an NP-complete problem may also be easy even when no general polynomial-time algorithm is known.

Does a polynomial algorithm guarantee practical speed?

No. Degree, constants, memory requirements and input representation matter. A bound is valuable because it explains scaling under a model, but choosing software also requires measurements on relevant inputs. Preserve the distinction between a mathematical guarantee and an engineering evaluation; neither replaces the other.

Is an unsuccessful solver proof that the specification is impossible?

Only if the solver has completed a sound method that establishes impossibility for the encoded specification. A crash, timeout or exhausted heuristic search is not enough. Even a valid infeasibility result concerns the model supplied: if the data or constraints misrepresent the real situation, the mathematical answer can be correct for the wrong question.

Why not use a complexity label as the whole explanation?

Because the label omits the mechanism needed to make decisions. A reader needs to know what is variable, which resource grows, what the output promises and which assumptions justify the claim. Being able to construct and check a small certificate or reduction is a better sign of understanding than confidently repeating “NP-hard” without specifying a problem.

Previous chapter · Contents · Next chapter

CHAPTER 14 OF 14 · Diagnose and learn

14. Build a four-week learning and checking project

Back to contents

Week one: establish the input contract

Choose one small graph task and the once-per-position subset-sum task. Write the allowed inputs, exact outputs and handling of empty lists, duplicate values and malformed certificates. Produce at least one yes-instance and one no-instance by hand. Keep each expected answer with a short independent justification so that a later program is checked against evidence rather than intuition.

Count representations as well as objects. Record the number of list entries, the maximum value, target magnitude and target digit length. For graphs, record vertices and edges separately. This simple notebook makes hidden parameter changes visible and prevents a later chart from describing several unrelated notions of “size” as though they were one quantity.

Week two: implement independent checking

Build a certificate checker before an elaborate solver. Feed it valid and invalid inputs, including repeated vertex names, absent vertices and subsets whose totals are close but unequal. Verify that it rejects for the intended reason. A checker that accepts everything makes a search demonstration look successful while destroying the meaning of success.

For very small instances, enumerate every candidate as a reference method. Compare its results with the dynamic programme or graph procedure. Exhaustive checking here is deliberately limited to a finite testing range. It can uncover implementation errors, but it is not a substitute for the invariant that explains why the algorithm works for arbitrary permitted inputs.

Week three: make one complete argument

Write out the independent-set to vertex-cover equivalence in both directions without consulting the worked example. Then explain the subset-sum invariant and why repeated items require a different update interpretation. If either explanation relies on “obviously,” replace that word with the actual case split. This makes the reasoning available to another reader who does not share your intuition.

Week four: change the context and report honestly

Run the three transfer exercises. Record the expected change before executing the program, then investigate disagreements. Report operation counts and measured times separately, identify the machine used for timing, and avoid fitting a sweeping asymptotic conclusion to a few tiny observations. Finish with one page explaining what was proved, what was tested and what remains unknown.

For further study, follow the linked MIT lecture for reductions, Cook’s formal description for P and NP, and the Yale subset-sum notes for a more detailed hardness construction. Return to Descriptive Complexity to see how logical expressiveness provides another route into resource classes. The lasting skill is to recognise exactly which claim an argument supports, then carry that discipline into the next unfamiliar computational problem.

Previous chapter · Contents · Gold Standard master