About this book
Computers and Intractability is a book about a single, stubborn fact of computing. Some problems can be solved quickly by a computer, and some, as far as anyone knows, cannot. The book does not prove that the hard problems are truly hard. Nobody has done that. What it does is more practical and, in its way, more surprising. It shows that a vast number of hard problems are hard in exactly the same way, so that a fast method for any one of them would give a fast method for all of them. It then teaches the reader how to show that a new problem belongs to this family.
Michael Garey and David Johnson wrote it at Bell Telephone Laboratories in Murray Hill, New Jersey, and W. H. Freeman published it in 1979. At that time the theory of NP-completeness was less than a decade old. Stephen Cook had published the founding result in 1971. Richard Karp had shown in 1972 that twenty-one well-known combinatorial problems were all equivalent in this sense. Leonid Levin had reached similar ideas independently in the Soviet Union. In the years that followed, hundreds of papers proved that one problem or another was NP-complete. The results were scattered across journals, conference proceedings and technical reports. A working engineer or a young researcher had no single place to learn the method or to find out whether a problem had already been classified.
Garey and Johnson set out to fill that gap. Their stated audience was wide: computer scientists, of course, but also operations researchers, engineers, applied mathematicians and anyone who designs algorithms for real tasks such as scheduling, routing, layout, packing and allocation. They assumed some mathematical maturity but not deep training in logic or automata. The book has a teacher's patience. It explains why the reader should care before it asks the reader to follow a proof.
The question at the centre of the book can be put simply. When you face a computational problem and cannot find a fast algorithm for it, how do you know whether to keep trying? The book's answer is that you can often prove that your problem is as hard as a whole class of problems that the best minds in the field have failed to solve efficiently. That proof does not close the door forever. It does tell you, with real force, that your time is better spent on approximation, on special cases, or on clever search than on the hunt for a perfect and fast general method.
The book has two halves of very different character. The first half is a course: definitions, the main theorem, the core hard problems, the techniques of proof, and then several chapters on what lies around and beyond the basic theory. The second half is a catalogue, an annotated list of more than three hundred NP-complete and related problems, grouped by field, each with a precise statement, its source and comments on variants. For decades that list was the first place a researcher looked. People referred to it simply by the authors' names, as one might refer to a dictionary.
It is worth saying at the start what the book is not. It is not a general textbook on algorithms. It does not teach sorting, data structures or dynamic programming in any detail. It is not a philosophical book about the limits of mind. It is a focused technical guide to one idea and its uses. Its focus is its strength. Few books in computing have stayed useful for so long while covering so narrow a topic.
The authors
Michael R. Garey and David S. Johnson were colleagues in the mathematics research centre at Bell Labs during the years when that institution was one of the great homes of applied mathematics and computer science. Bell Labs had produced the transistor, information theory, the Unix operating system and the C language. Its researchers were encouraged to work on deep questions that might, in time, matter to a telephone network. Problems of routing, switching, scheduling and circuit layout were not abstract there. They were daily engineering questions.
David S. Johnson
Johnson was born in 1945 and studied at Amherst and then at the Massachusetts Institute of Technology, where he completed a doctorate in 1973 on approximation algorithms for bin packing. Bin packing asks how to fit items of various sizes into the fewest possible bins of a fixed size. It is a hard problem, and Johnson's early work analysed simple rules, such as placing each item into the first bin where it fits, and proved how far from the best possible answer such rules could stray. This interest in what can be done when exact solution is out of reach runs through the whole book.
Johnson stayed at Bell Labs and its successor AT&T Labs for most of his career, and later taught at Columbia University. For many years he wrote a regular column on NP-completeness in the Journal of Algorithms, which continued the work of the book by reporting new results and new open problems. He also became a leading voice for the careful experimental study of algorithms: running heuristics on real and random instances and measuring how well they actually perform, rather than relying only on worst-case proofs. He organised the DIMACS implementation challenges, which set common test problems for researchers. He received the Knuth Prize for his contributions to the foundations of computer science. He died in 2016.
Michael R. Garey
Garey earned his doctorate at the University of Wisconsin and joined Bell Labs, where he worked for decades on scheduling theory, graph algorithms, bin packing and the complexity of combinatorial problems. Many of the early NP-completeness proofs for scheduling and graph problems carry the names Garey and Johnson together, often with a third co-author such as Larry Stockmeyer, Ravi Sethi or Robert Tarjan. Their joint papers in the mid-1970s established the hardness of problems such as graph colouring for planar graphs and various scheduling tasks, and they developed the notion of strong NP-completeness, which the book explains at length.
Why it matters that they wrote it
Garey and Johnson were not observers summarising a field from outside. They had proved many of the results in their own list. That gave the book an unusual authority and a working knowledge of where proofs go wrong. When they describe a technique, they describe it as people who had used it many times and knew which details tend to cause trouble. When they classify a problem as open, they had usually tried and failed to settle it themselves.
They also wrote from a place where theory met practice. The book never loses sight of the person who has a real problem to solve. That person wants to know whether the problem is hard, but also what to do next. This practical bent, combined with mathematical care, is a large part of why the book was used by engineers as well as theorists.
The shape of the argument
The book moves from motivation to theory, from theory to technique, and from technique to the wider landscape. It then hands the reader a reference tool. It is useful to see this structure in outline before reading, because the parts serve different purposes and reward different kinds of attention.
Motivation before formalism
The opening chapter speaks to the practical reader. It sets out the situation of a designer asked to produce an efficient method for some task, who tries and fails. The authors contrast three possible responses: to admit defeat, to claim that no efficient method exists, or to show that the task is equivalent to many famous problems that no one has solved efficiently. Only the third is both honest and achievable. The chapter is famous for a set of cartoons that make this point with humour. It also introduces the basic contrast between polynomial and exponential running times, with a table showing how quickly exponential growth outruns any practical machine.
Building the theory
The next stage gives careful definitions. It introduces decision problems, encoding schemes, languages, deterministic and nondeterministic Turing machines, the classes P and NP, polynomial transformations, and the definition of NP-completeness. It then proves Cook's theorem, which shows that Boolean satisfiability is NP-complete. The proof is presented in full, and it is the hardest piece of reasoning the beginner will meet in the book. Everything else rests on it.
Learning the craft
After the theory, the book turns to method. It presents six basic NP-complete problems and proves each one hard by building a transformation from a problem already known to be hard. It then organises the general craft of hardness proofs into three broad techniques and illustrates each with worked examples. This part is the practical heart of the book. It is where a reader learns to do something, not just to understand something.
Refining and extending
Later chapters refine the picture. One deals with problems involving numbers, where the size of the numbers matters, and introduces pseudo-polynomial algorithms and strong NP-completeness. Another extends the theory from decision problems to search and optimisation problems using more general kinds of reduction, and introduces NP-hardness. One chapter studies approximation: what can be said about methods that find good, but not optimal, answers. A final theoretical chapter looks beyond NP to the wider structure of complexity classes, including problems that appear to be harder still.
The catalogue
The second half is the appendix: a long, organised list of problems with short, exact statements and references. It is grouped into areas such as graph theory, network design, sets and partitions, storage and retrieval, sequencing and scheduling, mathematical programming, algebra and number theory, games and puzzles, logic, automata and languages, program optimisation, and a miscellaneous section. The list closes with a set of problems whose status was unknown at the time, which became a famous agenda for research.
A reader can treat the first half as a course and the second as a dictionary. Neither replaces the other. The course explains why the entries in the dictionary mean what they mean. The dictionary shows how far the ideas of the course reach.
Idea one: tractable means polynomial
The first idea in the book is a definition, and like many good definitions it carries an argument inside it. The book treats an algorithm as efficient, and a problem as tractable, if the number of steps grows no faster than some polynomial in the size of the input. If the input has n symbols, a running time proportional to n, or n squared, or n cubed counts as polynomial. A running time proportional to 2 raised to the power n does not.
Why draw the line there? Consider a simple experiment of thought. Suppose a machine does one billion basic steps per second. A method that needs n squared steps handles an input of size one thousand in a millionth of a second, and an input of size one million in about a quarter of an hour. A method that needs 2 to the power n steps handles size thirty in about a second, size fifty in about two weeks, and size one hundred in a time far longer than the age of the universe. Buying a computer a thousand times faster lets the polynomial method handle much larger inputs. It lets the exponential method handle only about ten more items. Exponential growth swamps hardware progress.
The polynomial boundary also has a pleasant robustness. If you compose two polynomial procedures, the result is still polynomial. The class does not depend much on the details of the machine model, as long as the model is reasonable. A problem solvable in polynomial time on one sensible model of computation is solvable in polynomial time on any other sensible model. That makes the class P a stable mathematical object rather than an artefact of one machine.
What the definition does not claim
The authors are careful about the limits of this idea, and the reader should be too. A running time of n to the power one hundred is polynomial but useless. A running time of 1.001 to the power n is exponential but, for moderate inputs, perfectly fine. Worst-case analysis can also mislead, since a method may be slow only on rare and contrived inputs. The simplex method for linear programming is the classic example: it can take exponential time on specially built examples yet runs quickly on almost all inputs met in practice.
Still, experience supports the convention. When a natural problem is shown to have a polynomial algorithm, the exponent usually turns out to be small, and later work often lowers it further. When no polynomial algorithm is known, the best known methods tend to be exhaustive search with clever pruning, and they really do collapse as inputs grow. The line between polynomial and exponential is not a law of nature, but it tracks a real difference in how problems behave.
Encoding and size
A quiet but important part of this idea is the notion of input size. To measure growth, one must fix how an input is written down. The book insists on reasonable encodings: numbers written in binary or decimal, graphs written as lists of vertices and edges, and no padding of the input to make an algorithm look faster than it is. This care matters most for problems involving numbers, because writing a number in binary takes space proportional to the number of its digits, not to its value. A later idea in the book turns entirely on this point.
Idea two: decision problems and the class NP
Most practical problems ask for something: the shortest tour, the best schedule, the largest group of mutually compatible items. The theory, however, works with decision problems, which ask only for a yes or no. Instead of asking for the shortest tour, one asks whether there is a tour of length at most some given bound. This change looks like a loss, but it costs little. If you could answer the yes-or-no version quickly, you could usually find the optimal value by trying bounds in a binary search, and often recover the solution itself by fixing parts of it one at a time. Conversely, if the yes-or-no version is hard, the optimisation version is at least as hard.
Decision problems have a technical advantage. Each one can be identified with a set of strings, the encodings of its yes instances. That lets the theory speak of problems as formal languages and of algorithms as machines that accept or reject strings. The connection to automata theory and to Turing machines is then direct.
Guess and check
The class NP is the heart of the book, and it is often explained badly. The letters stand for nondeterministic polynomial time. The cleanest way to understand the class is through verification. A decision problem is in NP if, whenever the answer is yes, there is a short certificate that proves it, and that certificate can be checked in polynomial time.
Take the problem of whether a set of cities has a tour of length at most a given bound. If the answer is yes, a certificate is simply such a tour. Given the tour, anyone can add up its length and check that it visits every city once. That takes little time. Finding the tour may be very hard, but checking a proposed tour is easy. The same pattern holds for scheduling, packing, colouring and covering problems. A good solution, once in hand, is easy to recognise.
The book presents this through a nondeterministic machine that first guesses a certificate and then checks it. The guess is not a real process. It is a way of describing the existence of a certificate. A nondeterministic machine accepts if some possible guess leads to acceptance. This model can feel strange at first. A helpful analogy is an exam with a magic oracle that writes down a proposed answer: the class NP contains problems where a student could at least confirm, quickly, that the oracle's yes answer was correct.
P inside NP, and the great question
Every problem in P is also in NP, because if you can solve a problem quickly, you can check a yes answer by solving it again and ignoring the certificate. The great open question is whether the reverse holds: whether every problem whose solutions are easy to check also has solutions that are easy to find. This is the P versus NP question. Almost every expert believes the answer is no, but no proof exists. The book states the question carefully and does not pretend to know more than anyone knows.
An important asymmetry hides here. NP is defined by short proofs of yes answers. It says nothing about no answers. Showing that no tour of length at most the bound exists may require looking at every tour. The class of problems with short proofs for no answers is called co-NP, and the book discusses it in its later chapters. Whether NP equals co-NP is another open question, closely tied to the first.
Idea three: reduction
The tool that makes the whole theory work is the polynomial transformation, today usually called a polynomial-time reduction. A reduction from problem A to problem B is a fast procedure that takes any instance of A and builds an instance of B with the same answer. If such a reduction exists, then a fast algorithm for B would give a fast algorithm for A: translate, then solve. In this sense B is at least as hard as A.
An everyday analogy helps. Suppose you have a device that can tell you whether any given jigsaw puzzle can be completed. Someone gives you a different kind of question, say whether a set of tiles can cover a floor. If you can quickly turn every floor question into a jigsaw question with the same answer, then your jigsaw device answers floor questions too. Floor tiling is no harder than jigsaws. If floor tiling is known to be very hard, then jigsaws must be very hard as well.
The direction of the arrow
The most common mistake among beginners is to reduce in the wrong direction. To show that your new problem is hard, you must reduce a known hard problem to your problem, not your problem to a known hard problem. Reducing your problem to satisfiability shows only that your problem is no harder than satisfiability, which is true of every problem in NP and tells you nothing. The book repeats this point and structures every example so that the direction is clear. Any student who works through its proofs absorbs the habit.
What a reduction must preserve
A reduction must do three things. It must run in polynomial time. It must map yes instances to yes instances. And it must map no instances to no instances, which is usually proved in the form that any yes answer for the constructed instance implies a yes answer for the original. Many faulty proofs check only one direction. The constructed instance has a solution whenever the original does, but the author forgets to show that the constructed instance has no unexpected solutions that do not correspond to anything in the original. The book's worked proofs always handle both directions explicitly.
Reductions are transitive. If A reduces to B and B reduces to C, then A reduces to C. This simple fact turns a collection of individual proofs into a connected web. Each new hardness proof extends the web. The catalogue in the second half of the book is, in effect, a map of that web.
Idea four: Cook's theorem and the first hard problem
Reductions let hardness spread from one problem to another, but something must start the chain. A problem is called NP-complete if it is in NP and every problem in NP reduces to it. The definition says nothing about whether such problems exist. Cook's theorem shows that they do, and that one of them is satisfiability.
Satisfiability, often shortened to SAT, asks a simple question about a logical formula built from variables that can be true or false. Is there some assignment of truth values that makes the whole formula true? The book uses the standard form in which the formula is a collection of clauses, each clause a list of variables or their negations, and the formula is true when every clause contains at least one true item.
The idea of the proof
The proof of Cook's theorem is the deepest single argument in the book. Its idea, however, can be explained without its details. Take any problem in NP. By definition there is a nondeterministic machine that decides it in polynomial time. For any particular input, that machine's possible computations are bounded: a polynomial number of steps, using a polynomial amount of tape. One can describe a whole computation as a large grid of facts: at step t, the head is at position i, the machine is in state q, cell j holds symbol s. Each fact becomes a Boolean variable.
Now write clauses that say the grid describes a legal computation: exactly one state at each step, exactly one symbol in each cell, the start matches the input, each step follows from the previous by a rule of the machine, and the machine ends in an accepting state. The formula is long, but only polynomially long. It is satisfiable exactly when some legal accepting computation exists, which is exactly when the original input is a yes instance. So every NP problem reduces to SAT.
The beauty of this argument is that it uses nothing about any particular problem. It works because computation itself, step by step, can be described by local logical constraints. SAT is a universal language for describing bounded searches. Once that is seen, its central place in the theory seems natural.
Why one is enough
After Cook's theorem, no one needs to repeat that construction. To show any new problem NP-complete, it suffices to show that it is in NP and that SAT, or any other problem already proved NP-complete, reduces to it. Karp used exactly this route to classify twenty-one problems in a single paper. The book builds on the same base, and the rest of its theory is largely about how to construct such reductions well.
A related result, often attributed jointly to Cook and Levin, is sometimes presented in other books with different machinery, such as Boolean circuits instead of Turing machines. The core insight is the same. A reader who later meets the circuit version should recognise it as the same theorem seen through a different lens.
Idea five: a small toolkit of hard problems
A carpenter does not forge a new hammer for every job. In the same way, a person proving hardness does not start from SAT every time. The book picks out six problems that serve as reliable starting points. Each is proved NP-complete early, and together they cover the main kinds of structure that new problems tend to have.
- Three-satisfiability: satisfiability restricted to clauses with exactly three items. It keeps all the hardness of SAT but has a uniform shape that is easy to encode into other problems.
- Three-dimensional matching: given triples drawn from three sets of equal size, can one choose triples that use every element exactly once? It suits problems about assignment and exact covering.
- Vertex cover: can one choose a small set of vertices in a graph so that every edge touches at least one chosen vertex? It suits problems about selection in networks.
- Clique: does a graph contain a group of a given size in which every pair is connected? It is closely tied to vertex cover and to independent set.
- Hamiltonian circuit: is there a cycle through a graph that visits every vertex exactly once? It suits problems about tours, orderings and sequences.
- Partition: can a list of whole numbers be split into two groups with equal sums? It suits problems about numbers, sizes, weights and budgets.
The choice is deliberate. When you meet a new problem, you look at its structure and ask which of the six it most resembles. A scheduling problem with job lengths that must add up neatly smells of partition. A routing problem that must visit every place smells of Hamiltonian circuit. A problem about choosing a few items that touch everything smells of vertex cover. The right starting point often makes the difference between a two-line proof and a ten-page one.
Knowing the six problems well is like knowing a handful of standard openings in chess. It does not decide the game, but it gives you a sound position from which to work. The book proves each of them carefully, and the proofs are themselves models of the techniques that come next.
Idea six: three ways to build a reduction
The most valuable teaching in the book is its classification of how hardness proofs are built. The authors describe three broad techniques. They do not claim that every proof fits exactly one. They offer the categories as a way of thinking, a set of questions to ask when facing a new problem.
Restriction
The simplest technique is to notice that your problem contains a known hard problem as a special case. If you can restrict the inputs of your problem so that it becomes exactly a known NP-complete problem, you are done, since a problem cannot be easier than one of its own special cases. For example, a general problem of scheduling tasks on machines with various constraints may, when all tasks have certain lengths and there are two machines, become partition. A general routing problem may, when all distances are one or two, become Hamiltonian circuit.
Restriction proofs are short, and the book encourages trying them first. Many published proofs that look elaborate could have been done by restriction. The skill lies in seeing which constraints to fix and which to leave free. One useful habit is to set as many parameters as possible to trivial values and ask what hard core remains.
Local replacement
The second technique takes the pieces of a known hard instance and replaces each piece with a small structure in the new problem, all in the same way. If the source is a formula, each clause might be replaced by a small fixed gadget. If the source is a graph, each edge might be replaced by a small chain or triangle. The replacement is local: each piece is handled on its own, without reference to the others, and the new instance is the union of the replacements.
An image helps. Think of translating a text word by word, where each word has a fixed translation and grammar does not shift. Such a translation is easy to build and easy to check. Local replacement works when the target problem is close enough to the source that a word-by-word translation keeps the meaning.
Component design
The third technique is the most demanding and the most creative. It builds the new instance from components that play distinct roles. Some components represent choices, such as setting a variable true or false. Others represent tests, such as checking that a clause is satisfied. Connections between them make the choices and the tests interact in just the right way. The classic proofs that three-dimensional matching and Hamiltonian circuit are NP-complete use this method, with gadgets for variables, gadgets for clauses, and wiring that forces consistency.
Component design resembles engineering a circuit. You decide what each part must do, build each part, and then wire them so that the whole behaves as intended. The hard part of the proof is usually to show that no unintended behaviour sneaks in: that the only way to solve the constructed instance is to make consistent choices. The book walks through such proofs slowly, and a reader who follows one with a pencil learns more than from many pages of description.
Why the classification helps
Without a framework, hardness proofs can look like magic. Each seems to rely on a trick that came from nowhere. The three categories make the craft teachable. They tell a beginner to try restriction first, then to ask whether a uniform translation is possible, and only then to design specialised components. This order saves time and builds judgement.
Idea seven: numbers, pseudo-polynomial time and strong hardness
One of the most subtle ideas in the book concerns problems that involve numbers. Partition, the knapsack problem and many scheduling problems ask about sums of integers. These problems are NP-complete, yet in practice they are often easy. The book explains why, and the explanation adds an important refinement to the theory.
Consider partition. A simple method called dynamic programming keeps a table of which sums can be reached using the first few numbers. The table has one row per number and one column per possible sum up to half the total. Filling it takes time proportional to the count of numbers times the size of the total. If the numbers are small, say less than a thousand, this is fast. If the numbers have a hundred digits each, the table is astronomically large.
Is that method polynomial? It depends on how size is measured. The input size counts the digits of the numbers, not their values. A number with a hundred digits takes about a hundred symbols to write, but its value is about ten to the power one hundred. The dynamic programming method is polynomial in the values but exponential in the digits. The book calls such a method pseudo-polynomial.
Strong and weak
This leads to a split among NP-complete problems. Some, like partition and knapsack, become easy when the numbers in them are bounded by a polynomial in the input length. Their hardness lives only in large numbers. Others remain NP-complete even when every number in them is small. The book calls these strongly NP-complete. Three-partition, a cousin of partition in which numbers must be grouped into triples with equal sums, is the standard example. Problems without numbers at all, such as Hamiltonian circuit and clique, are trivially strongly NP-complete.
The distinction has real consequences. For a weakly hard problem, a pseudo-polynomial algorithm may be perfectly usable on real data where numbers are modest. A strongly hard problem offers no such escape, unless P equals NP. Strong hardness also rules out certain kinds of very good approximation schemes, which ties this chapter to the later chapter on approximation. Anyone working on scheduling, budgeting or packing should know which kind of hardness they face.
A common confusion
Students sometimes think that a fast dynamic programming solution to knapsack contradicts its NP-completeness. It does not. The contradiction disappears once one remembers that the input measures numbers by their length in digits. The book's careful treatment of encodings at the start pays off here. It is one of the clearest places in the subject where precise definitions prevent a real misunderstanding.
Idea eight: from decisions to optimisation
Engineers rarely care about yes or no. They want the best schedule or the cheapest network. The book therefore extends the theory beyond decision problems. It introduces a more general kind of reduction, often called a Turing reduction, in which an algorithm for one problem may call an algorithm for another many times, as a subroutine, and combine the answers. Under this broader notion, one can compare the difficulty of search and optimisation problems.
A problem is called NP-hard if every problem in NP reduces to it in this broader sense, whether or not the problem itself is in NP. Optimisation versions of NP-complete problems are NP-hard. So are some problems that are not even decision problems, and some that may be harder than anything in NP. The label NP-hard is the one engineers most often need. It means: a fast exact algorithm for this would give fast algorithms for every problem in NP.
Why the distinction is worth keeping
In casual speech the terms NP-complete and NP-hard are often mixed. The book keeps them apart. NP-complete is a precise property of decision problems that are both in NP and as hard as any problem in NP. NP-hard says only the second half. A problem can be NP-hard and far harder than NP, as some problems in the later chapters are. Keeping the terms distinct avoids claims that are false or meaningless.
This chapter also discusses problems that are NP-hard but whose decision versions may not be in NP, and the class of problems that are NP-easy, solvable in polynomial time with access to an NP oracle. These terms are less used today, but the ideas behind them remain the standard way of relating optimisation to decision.
Idea nine: approximation
If exact solutions are out of reach, the next question is how close one can get. The book devotes a chapter to approximation algorithms, which run in polynomial time and guarantee an answer within some known factor of the best. This chapter reflects Johnson's own early research, and it points toward one of the largest areas of later work.
The results fall into a pattern. For some problems, good approximation is easy. For bin packing, the simple rule of putting each item into the first bin with room never uses more than about seventeen tenths of the optimal number of bins, plus a small constant, and better rules do better still. For some problems, approximation can be made as good as one likes, at a price in running time. Knapsack has such a scheme, built by rounding the numbers and applying pseudo-polynomial dynamic programming to the rounded instance. For other problems, approximation is itself hard. For the general travelling salesman problem, with arbitrary distances, finding a tour within any fixed factor of the best is NP-hard, because such an algorithm could be used to decide Hamiltonian circuit.
How hardness of approximation is proved
The last example shows a key trick. Build an instance in which the yes answers have small cost and the no answers have very large cost, with a wide gap between. An approximation algorithm good enough to tell the two apart would then solve the hard decision problem. This gap technique is simple, and in 1979 it gave only a few strong results. Much later, in the 1990s, the PCP theorem gave a general and powerful way to create such gaps, and the theory of inapproximability grew into a large field. The book sits at the start of that story.
What approximation is often confused with
An approximation algorithm, in this sense, comes with a proved guarantee. A heuristic is a method that often works well but has no guarantee. Both are useful. The book treats heuristics with respect, and Johnson's later career was partly about measuring them carefully. But it is important not to mistake a heuristic that did well on test data for an algorithm with a proved bound. The chapter keeps these categories clear.
Idea ten: beyond NP
The final theoretical chapter widens the frame. NP is one class in a larger structure of complexity classes, and some natural problems seem to lie above it. The book introduces co-NP, the complements of NP problems, and discusses why problems that are NP-complete are unlikely to be in co-NP. It introduces the polynomial hierarchy, a tower of classes built by allowing alternating layers of existence and universality in the definition of a problem. It introduces PSPACE, the problems solvable with a polynomial amount of memory, and gives natural complete problems for it, many drawn from games where two players alternate moves.
Games illustrate the step beyond NP well. To decide whether a puzzle has a solution is to ask whether there exists a sequence of moves that works. To decide whether the first player in a two-player game has a winning strategy is to ask whether there is a move such that for every reply there is a move such that for every reply, and so on. The alternation of there exists and for all is what pushes such problems up the hierarchy. Generalised versions of board games, played on boards of growing size, often turn out to be PSPACE-complete or harder.
The chapter also discusses problems believed to lie between P and NP-complete, neither easy nor among the hardest. Graph isomorphism, the problem of deciding whether two graphs are the same up to relabelling, is the most famous candidate. The book explains a result of Ladner showing that if P differs from NP, then such intermediate problems must exist. The chapter is brief and dense. It gives the reader a map of the territory rather than a full tour.
The catalogue as a working tool
The appendix deserves its own discussion because it changed how people worked. Before it, a researcher who suspected a problem was hard had to search through scattered literature or prove the result alone. After it, the first step was to look up the problem, or something close to it, in the list. Each entry gives the problem a short name and a code, states the instance and the question precisely, cites the source of the hardness proof, and notes related variants: which special cases are easy, which remain hard, and which were open.
The comments on variants are often the most useful part. They show how hardness changes as a problem is restricted. A graph problem may be hard in general, hard on planar graphs, easy on trees and open on some other family. Reading a few dozen entries teaches a sense of where the boundary between easy and hard tends to fall. That sense is part of the expertise the book transmits.
The catalogue also ends with a short list of open problems, and this list became a research agenda. Several of its entries were later settled. Linear programming was shown to be solvable in polynomial time by the ellipsoid method of Khachiyan, announced in 1979, the year the book appeared. Primality testing was shown to be in P in 2002 by Agrawal, Kayal and Saxena. Graph isomorphism remains unresolved, though in 2015 László Babai announced an algorithm that runs in quasi-polynomial time, far faster than earlier methods. Several other entries were resolved during the decades in which Johnson's column kept the list current.
Using the list well
The list rewards a particular way of searching. Problems rarely arrive with their textbook names. A manager may describe a task as assigning shifts, a chip designer as placing blocks, a logistics planner as loading trucks. The first job is to strip away the setting and state the bare combinatorial question: what are the objects, what are the constraints, what is being counted or optimised. Once the question is bare, it often matches an entry or sits close to one. The grouping by area helps, since a packing question will usually be found among sets and partitions or among storage problems, and a timing question among sequencing and scheduling.
When no entry matches exactly, a near match is still valuable. If a closely related problem is listed as hard, its proof usually suggests how to prove your own problem hard, often by restriction. If a closely related problem is listed as easy, that is a warning: perhaps your problem is easy too, and you should look for the extra constraint that might make it hard or the structure that might make it tractable. The notes on variants are a guide to exactly these borders.
A third use is negative. Before announcing that a problem is hard, check that it is not a special case of something known to be easy. Problems on trees, on interval graphs, or with only two machines often collapse into polynomial time. The list records many such cases. Reading it this way protects the reader from a common embarrassment: proving hardness for the general case while the instances that actually arise belong to an easy special family.
The tradition around it
The book stands where two older lines of thought meet. One is the logical study of computability that began in the 1930s with Gödel, Church, Turing and Post. That tradition asked which problems can be solved by any mechanical procedure at all. Its central results, such as the undecidability of the halting problem, appear in The Undecidable, the collection of founding papers edited by Martin Davis that sits elsewhere in this bay. NP-completeness takes the same tools, Turing machines and reductions, and asks a finer question: not whether a problem can be solved, but whether it can be solved in a reasonable time.
The other line is the study of efficient algorithms and combinatorial optimisation. In the 1960s, Jack Edmonds argued that polynomial running time was the right notion of a good algorithm, in work on matching in graphs. Alan Cobham made a similar proposal. Operations researchers had long struggled with integer programming, scheduling and routing. Donald Knuth's The Art of Computer Programming, also on this shelf, made the precise analysis of algorithms a discipline. Garey and Johnson's book joins these lines by giving a rigorous reason why certain optimisation problems resist efficient algorithms.
Neighbours on the shelf
Hopcroft and Ullman's Introduction to Automata Theory, Languages, and Computation and Sipser's Introduction to the Theory of Computation both contain chapters on NP-completeness, written for a general course in the theory of computation. They are the natural place to learn Turing machines and the basic definitions before or alongside this book. Sipser in particular gives an exceptionally clear account of Cook's theorem and of the classes beyond NP. Introduction to Algorithms by Cormen, Leiserson and Rivest presents the theory from the algorithm designer's side, with a chapter on NP-completeness and another on approximation.
Minsky's Computation: Finite and Infinite Machines belongs to the generation just before NP-completeness. It treats machines and computability with great clarity but predates the complexity view. Reading it alongside Garey and Johnson shows how the question shifted from can to how fast. Penrose's The Emperor's New Mind discusses complexity briefly in its larger argument about mind and computation. Nielsen and Chuang's Quantum Computation and Quantum Information takes the story in a new direction: it asks which problems a quantum computer might solve faster, and it explains why quantum computers are not believed to solve NP-complete problems efficiently either.
What came after
The theory grew in several directions after 1979. Randomised algorithms and the classes they define became a central topic. Interactive proofs and probabilistically checkable proofs transformed the understanding of verification and gave rise to the modern theory of hardness of approximation. Parameterised complexity, developed by Downey and Fellows in the 1990s, asked whether hardness can be confined to a single small parameter of the input. The exponential time hypothesis, formulated by Impagliazzo and Paturi, gave a sharper conjecture than P not equal to NP and allowed finer claims about exact running times. Average-case complexity studied problems that are hard on typical inputs, which matters for cryptography.
On the practical side, SAT solvers improved enormously. Programs built on clause learning and careful search now solve industrial instances with millions of variables, in hardware verification, planning and software testing. This does not contradict NP-completeness, which is a statement about the worst case. It does show that hardness in the worst case and difficulty in practice are different things, a point the book itself makes but which later events made vivid.
Questions and criticisms
Few books in computing have aged as gracefully, but it is fair to ask what a modern reader should keep in mind.
Worst case is not the whole story
The theory classifies problems by their hardest instances. Real data is often far from the worst case. Travelling salesman instances with hundreds of thousands of cities have been solved to proven optimality. Large scheduling and packing problems are solved daily by commercial software. A reader who takes NP-completeness to mean that a problem cannot be solved in practice will be wrong. The book's claim is narrower and correct: no algorithm is known that is fast on every instance, and finding one would settle a major open question. The practical lesson is to change strategy, not to give up.
The polynomial convention
Some critics argue that the line between polynomial and exponential is too coarse. A polynomial algorithm with a huge exponent or huge constant can be useless, and an exponential algorithm with a small base can be practical. Later work responded with finer measures: fine-grained complexity studies exact exponents within P, and parameterised complexity measures how running time depends on separate features of the input. These developments refine the book's framework rather than replace it.
The reliance on an unproved conjecture
Everything in the book is conditional on P being different from NP. If the conjecture were false, the classification would collapse. Most researchers think this unlikely, partly because of the sheer number of independent failures to find fast algorithms for NP-complete problems, and partly because a world in which P equals NP would make finding proofs as easy as checking them, which seems implausible. Still, a careful reader should notice that NP-completeness is evidence of hardness, not proof. The book itself says this clearly.
Dated material
The appendix reflects knowledge as of the late 1970s. Some entries listed as open have been settled, as noted above. Some variants have been reclassified. Newer catalogues and online compendiums of problems, and surveys on approximability, should be consulted for current status. The notation is sometimes old-fashioned, and the Turing machine presentation is heavier than in modern texts. None of this damages the core teaching. The definitions, the main theorem and the techniques of reduction are taught much the same way today.
What has held up
The central framework has held up completely. P, NP, reductions, NP-completeness, NP-hardness, strong NP-completeness and pseudo-polynomial algorithms remain standard concepts, defined as the book defines them. The three techniques of reduction are still taught. The habit of asking whether a problem is NP-hard before seeking an exact fast algorithm is now part of ordinary engineering judgement. The book's tone, honest about what is known and unknown, remains a model.
Why it is on this shelf
This shelf gathers books that help a reader understand how things are put together: the self in Vedanta, the patterns of the sky in Jyotish, the laws of nature in science, the behaviour of markets in economics, and the machines of technology. Garey and Johnson belong here because they teach a kind of knowledge that is rare and valuable: knowledge of limits. Most books on computing tell you how to do something. This one tells you when a certain kind of doing is, as far as anyone knows, out of reach, and what to do instead.
That lesson travels well beyond computing. Economists face allocation problems that are formally NP-hard, and the theory explains why markets and institutions often rely on rules of thumb rather than exact optimisation. Astrologers and astronomers who compute charts and ephemerides deal with tractable calculation, but anyone who tries to search a vast space of combinations, of planetary configurations or of schedules, will meet the same explosive growth that the book describes. A student of Vedanta, which distinguishes carefully between what can be known by a method and what cannot, may find something familiar in a book that is so exact about the reach of method.
We keep it also because it is a model of how to write a technical guide. It is clear about definitions, generous with examples, honest about open questions, and organised so that it serves both the learner and the practitioner. Its appendix is one of the great reference works of applied mathematics. It sits naturally beside the theory texts in this bay and gives them a practical edge.
How to read it
The book can be read in a few weeks by someone with a little background in discrete mathematics and some familiarity with algorithms. A reader without that background should first read the chapters on Turing machines and computational complexity in Sipser, or the corresponding parts of Hopcroft and Ullman, and then come here.
A first pass
- Read the first chapter in one sitting. Enjoy the cartoons and the growth table. Make sure the contrast between polynomial and exponential time feels real to you.
- Read the second chapter slowly. Write down the definitions of P, NP, polynomial transformation and NP-complete in your own words. Work through the proof of Cook's theorem with paper, building a tiny example machine and the clauses that describe it.
- Read the third chapter with a pencil. For each of the six basic problems, redraw the reduction yourself and check both directions of the proof.
- Then browse the appendix for an hour. Find problems from areas you know. Read the comments on variants and notice where hardness appears and disappears.
A second pass
- Read the chapter on number problems and strong NP-completeness. Write out the dynamic programming solution to partition and explain to yourself why it is pseudo-polynomial.
- Read the chapter on NP-hardness and the chapter on approximation together. Prove for yourself the gap argument for the general travelling salesman problem.
- Read the final theoretical chapter last, and supplement it with a modern account of the polynomial hierarchy and PSPACE.
What to skip at first
On a first reading one may skip the more technical sections on encodings and on the finer variants of reducibility. They matter, but they are easier to understand after the main line is clear. One may also skip detailed proofs in the later chapters that rely on long constructions, returning to them only if needed.
Practice
The real test of understanding is to prove a problem NP-complete yourself. Choose a problem from your own work or from a puzzle you enjoy. Decide which of the six basic problems it resembles. Try restriction first. If that fails, attempt a local replacement, and only then design components. Check both directions. Then look in the appendix to see whether the problem is already there and how the original authors did it.
What to read next from this shelf
For the logical background, read The Undecidable and then Sipser's Introduction to the Theory of Computation. For the algorithmic side, read the chapters on NP-completeness and approximation in Introduction to Algorithms. For the wider question of what computation can and cannot do, read Penrose's The Emperor's New Mind critically, and Nielsen and Chuang for the quantum view. For the human story behind the machines, read Hodges's Alan Turing: The Enigma.
Questions to carry
- Why is the boundary between polynomial and exponential time a sensible definition of efficiency, and where does it fail?
- What exactly does it mean for a problem to be in NP, and why is verification the cleanest way to say it?
- In a hardness proof, why must the known hard problem be reduced to the new one and not the other way round?
- What feature of computation makes it possible to describe any bounded computation as a satisfiability formula?
- Why does it suffice to prove one problem NP-complete from scratch and all others by reduction?
- Given a new problem, how would you decide which of the six basic problems to reduce from?
- When does restriction give a complete proof, and when is component design needed?
- Why does the dynamic programming algorithm for knapsack not show that P equals NP?
- What is the practical difference between a weakly and a strongly NP-complete scheduling problem?
- How can a problem be NP-hard without being in NP?
- Why can some NP-hard problems be approximated well while others cannot be approximated at all?
- What does the alternation of exists and for all add to the difficulty of a problem?
- If a SAT solver handles millions of variables in practice, in what sense is SAT still hard?
- What would change in the world, and what would not, if someone proved that P equals NP?
Words to know
- Algorithm: a precise step-by-step method for solving every instance of a problem.
- Instance: one particular input to a problem, such as one specific graph or list of numbers.
- Decision problem: a problem whose answer is yes or no for each instance.
- Polynomial time: running time bounded by a fixed power of the input size.
- Exponential time: running time that grows like a constant raised to a power of the input size.
- P: the class of decision problems solvable in polynomial time by a deterministic machine.
- NP: the class of decision problems whose yes answers have short certificates checkable in polynomial time.
- co-NP: the class of decision problems whose no answers have short certificates checkable in polynomial time.
- Certificate: a piece of evidence, such as a proposed solution, that lets a checker confirm a yes answer quickly.
- Nondeterministic machine: an abstract machine that may choose among several moves and accepts if any sequence of choices leads to acceptance.
- Polynomial transformation: a fast translation of instances of one problem into instances of another with the same answers; also called a reduction.
- Turing reduction: a reduction that may call a solver for another problem many times as a subroutine.
- NP-complete: a problem in NP to which every problem in NP can be reduced.
- NP-hard: a problem to which every problem in NP can be reduced, whether or not it lies in NP.
- Satisfiability (SAT): the problem of deciding whether a Boolean formula has an assignment that makes it true.
- Cook's theorem: the result that satisfiability is NP-complete, proved by Stephen Cook in 1971.
- Gadget: a small structure in a reduction that represents a variable, a clause or another piece of the source problem.
- Pseudo-polynomial algorithm: an algorithm whose running time is polynomial in the numeric values in the input but not in their length in digits.
- Strongly NP-complete: NP-complete even when all numbers in the instance are bounded by a polynomial in the input size.
- Approximation algorithm: a polynomial-time method with a proved guarantee on how far its answer can be from the best.
- Heuristic: a method that often works well in practice but has no proved guarantee.
- Polynomial hierarchy: a tower of complexity classes defined by alternating layers of existence and universality.
- PSPACE: the class of problems solvable with a polynomial amount of memory, regardless of time.
- Intermediate problem: a problem in NP that is neither in P nor NP-complete, which must exist if P differs from NP.
A note on this edition
This is a study edition written for this shelf in our own words. It describes and explains Computers and Intractability but does not reproduce it. The examples, analogies and summaries here are ours. The book itself is still in copyright. It is widely held by university libraries and remains in print, and it is well worth getting a copy to work through with a pencil, especially its proofs and its catalogue of problems.