Heuristics

Are Heuristics Good or Bad?

Heuristics are neither good nor bad on their own. Learn when giving up guarantees for speed pays off, the main ways heuristics mislead, and how to decide.

On this page
  1. The short answer
  2. When a heuristic is a good choice
  3. When a heuristic causes problems
  4. How to decide
  5. Key takeaways

The short answer

Neither, by default. A heuristic is a tool, and whether it is a good choice depends on the problem, the time available and the cost of a wrong answer. If an exact method is too slow and a reasonable answer is good enough, a heuristic is usually the better option. If a poor answer would be costly and an exact method is fast enough, a heuristic may be the wrong choice.

When a heuristic is a good choice

  • The exact method is too slow. A route planner for many stops cannot check every order of visits in a practical time. A heuristic that returns a reasonable route in moments can be far more useful than an exact answer that never arrives. Whether an exact method is practical depends on its running time, which is part of how to know if an algorithm is reasonable or unreasonable.
  • A good-enough answer is acceptable. Many everyday software tasks, such as ordering a list of suggestions or choosing a server for a request, do not need the single best choice.
  • The heuristic keeps a guarantee. Some heuristics do not give up correctness. In A* search, a heuristic estimate that never overestimates the remaining distance still leads to a shortest path. So the choice is not always speed against accuracy.
  • It is simple to build and check. A short rule can be easier to understand, test and maintain than a complex exact method.

When a heuristic causes problems

  • No guarantee of quality. A heuristic may return an answer that is far from the best one, and it may be hard to say how far.
  • Getting stuck. Local search can stop at a local optimum, a solution that no small change improves, even when a much better one exists elsewhere.
  • Poor fit to the input. A rule that works well on one kind of problem can do badly on another. The no free lunch theorems suggest that no single method is best across all problems, so testing on realistic inputs matters.
  • Predictable human errors. In psychology, heuristics are mental shortcuts. Tversky and Kahneman described the availability heuristic, in which people judge how likely something is by how easily examples come to mind. That shortcut can lead to systematic errors.

How to decide

Ask these questions before you choose a heuristic:

  1. Does an exact method finish in an acceptable time on the inputs you really have?
  2. How costly is a suboptimal answer, and who bears that cost?
  3. Can you measure answer quality? For example, compare the heuristic with exact results on small cases.
  4. Have you tested it on inputs like the ones you expect in use, not only on easy examples?
  5. Does the method come with a guarantee? If not, can you check its answers?

Where errors are costly, such as in safety-critical systems, treat a heuristic as one input among others, with checks and fallback behavior, rather than trusting it alone.

Key takeaways

  • Heuristics are a good choice when exact answers are too slow and a reasonable answer is enough.
  • They are risky when a wrong answer is costly, when they can get stuck, or when they are applied to inputs they were not tested on.
  • Some heuristics keep correctness, so the choice is not always a trade.
  • Before relying on a heuristic, compare it with exact results on small cases and test it on realistic inputs.

The complete guide to heuristics

What Are Heuristics in Computer Science?
Read the guide

Keep exploring

Guides from other topics

All topics →

AVL Trees in Data Structures

An AVL tree is a self-balancing binary search tree. Learn how balance factors and rotations keep search, insert, and delete at O(log n) in the worst case.

AVL Trees 4 min read