Undecidable and Unreasonable Problems

Undecidable Problems and Unreasonable Time Algorithms

Learn the difference between undecidable problems, which no algorithm can always solve, and problems whose known algorithms are too slow to use in practice.

On this page
  1. Two different kinds of hard
  2. What makes a problem undecidable
  3. What makes a problem take unreasonable time
  4. Why polynomial time is the practical line
  5. Undecidable and unreasonable side by side
  6. Where P versus NP fits
  7. What to do with a hard problem
  8. Common misunderstandings
  9. Key takeaways

Two different kinds of hard

Undecidable problems and unreasonable time algorithms are both limits on computing, but they are different limits. An undecidable problem has no algorithm that gives the correct answer for every possible input, no matter how much time is available. An unreasonable time problem does have a correct algorithm, but its running time grows so quickly that the answer can take far longer than is practical.

What makes a problem undecidable

A problem is undecidable when no single algorithm can answer it correctly for all inputs. The best-known example is the halting problem: given a program and an input, decide whether the program eventually stops or runs forever. Alan Turing showed in his 1936 paper “On Computable Numbers” that no general procedure can do this for every program.

This result does not depend on hardware. A faster computer or more memory does not change the answer. For some specific programs the question is easy. A program with no loops, for example, always stops. The impossibility applies to the general problem, meaning every program and every input.

Rice’s theorem extends the idea. It says that for any property of what a program computes, if some programs have that property and others do not, no algorithm can decide it correctly for all programs.

The halting problem also has a lopsided shape. If a program stops, you can confirm that by running it and waiting. If it never stops, no finite amount of waiting proves that in general.

What makes a problem take unreasonable time

Here a correct algorithm exists and always finishes. The trouble is how its running time grows as the input gets bigger. Computer scientists describe that growth with Big O notation.

Running times that grow as a polynomial in n, such as n, n log n, n^2 or n^3, are usually called reasonable. Running times that grow exponentially, such as 2^n, or faster still, such as n factorial, are usually called unreasonable.

Brute force algorithm examples show the pattern well. Checking every subset of a list with n items means examining 2^n subsets, and each added item doubles the work. The table below uses rounded numbers and assumes a billion simple steps per second.

Input size n Approximate steps Approximate time
30 10^9 about 1 second
40 10^12 about 18 minutes
50 10^15 about 13 days
60 10^18 about 36 years

Real machines differ in speed, but the pattern holds. Exponential growth quickly outpaces any fixed hardware upgrade.

Why polynomial time is the practical line

In 1965, Alan Cobham and Jack Edmonds both pointed to polynomial time as the line between feasible and infeasible computation. The idea is now called the Cobham-Edmonds thesis, and it is a rule of thumb rather than a law.

A polynomial-time algorithm can still be impractical if its exponent is large. An exponential algorithm can be fine for small inputs. So a polynomial label tells you the problem scales more gracefully, not that every polynomial algorithm will be fast.

Undecidable and unreasonable side by side

Undecidable problem Unreasonable time problem
Correct algorithm for every input? No Yes
What goes wrong No algorithm can always answer correctly Correct answers take too long for large inputs
Does faster hardware help? Not in principle A little, but growth outpaces it
Typical example The halting problem Trying every subset of a large list

Where P versus NP fits

Many important problems, such as the exact traveling salesman problem, which asks for the shortest route through a set of cities, have no known polynomial-time algorithm. Whether such algorithms exist is the P versus NP question. It remains unresolved. Most researchers expect that no polynomial-time algorithm exists for these problems, but nobody has proved it.

What to do with a hard problem

When a problem is unreasonable, several approaches help:

  • Check whether your inputs are small enough for an exponential algorithm to finish.
  • Use heuristics. These are rules of thumb that produce good answers quickly, without guaranteeing the best one. A common search is “what are heuristics in computer science”, and the short answer is that they trade guarantees for speed.
  • Use approximation algorithms, which give answers within a known margin of the best possible for some problems.
  • Look for special structure. Some problems that look exponential can be solved in polynomial time by a cleverer method. Dynamic programming is one example, and the comparison of “divide and conquer algorithm vs dynamic programming” is a good next step.

When a problem is undecidable, there is no general algorithm to find, so the practical options are different. Antivirus software is a good example. No program can perfectly decide whether every other program is malicious, so these tools use heuristics and accept some false alarms and missed threats.

Common misunderstandings

  • “Undecidable just means very hard.” It means no algorithm can do the job for all inputs, however much time you give it.
  • “Polynomial means fast.” Not necessarily. A running time of n to the power 100 is polynomial but impractical for most inputs.
  • “Exponential always means useless.” Not always. The simplex method for linear programming has exponential worst-case time, yet it is widely used in practice.

Key takeaways

  • An undecidable problem has no algorithm that always gives the right answer.
  • An unreasonable time problem has a correct algorithm, but it becomes impractical as inputs grow.
  • Polynomial time is the usual practical dividing line.
  • When you hit either limit, look at heuristics, approximations, smaller inputs, or a more clever method.

Keep exploring

Guides from other topics

All topics →