ComparisonThinking and intelligence

Heuristic vs Algorithm: Two Ways to Solve Problems Compared

Diagram of the A* search algorithm, which uses a heuristic estimate to choose which node to explore next in a graph
Diagram of the A* search algorithm, which uses a heuristic estimate to choose which node to explore next in a graph. Image: Sargeras at de.wikipedia (Public domain), via Wikimedia Commons

An algorithm is a step-by-step procedure that reliably reaches a correct answer when it is followed properly. A heuristic is a rule of thumb that usually reaches a good answer more quickly, but with no guarantee that it is correct. The two are often compared in psychology, computing and mathematics because they represent two different ways of solving problems.

For general education about psychology, not medical or psychological advice. Disclaimer.

Heuristic vs Algorithm at a glance

FeatureHeuristicAlgorithm
Guarantee of a correct answerNot guaranteed; a heuristic gives a good answer that may be wrongGuaranteed if applied correctly and the problem has a solution
SpeedUsually fast, because it uses few steps and little informationOften slow, because it may need many steps or a complete search
Information neededUses a few cues or a partial view of the problemUses all the information the procedure requires
Typical errorsSystematic biases, such as anchoring or availabilityMistakes in the procedure itself, or an impractical number of steps
Origin in psychologySimon (1950s); Tversky and Kahneman (1974); Gigerenzer (1999)A long-standing idea in mathematics and logic, used as a model of procedures
Example from everyday lifeJudging how common a risk is by how easily examples come to mindTrying every combination on a lock with a known number of digits

The main difference

The key difference is the guarantee. An algorithm specifies every step so that, given enough time and the right input, it will produce the correct output. A heuristic specifies a shortcut that tends to work but can fail in cases its designer did not foresee.

Both strategies trade effort against accuracy. An algorithm may be slow or impractical when the number of possibilities is very large. A heuristic can be fast and efficient, but it accepts the possibility of error. Psychologists use the contrast to explain why people often choose shortcuts when a full procedure would take too long.

In plain terms, an algorithm tells you how to find the answer, while a heuristic tells you where the answer is likely to be. The distinction matters in both human thinking and machine problem solving.

Origins and founders

The concept of an algorithm is much older than the psychology of heuristics. Procedures with fixed steps were used in arithmetic and logic for centuries, and the word itself derives from the name of the Persian mathematician al-Khwarizmi, whose work on calculation was translated into Latin in the 12th century. Mathematicians later formalised algorithms as precise procedures.

The modern idea of heuristics developed mainly in the 20th century. Herbert A. Simon argued in the 1950s that people cannot make fully rational choices because of limited information and time, and that they use satisficing rules instead. In 1968 Peter Hart, Nils Nilsson and Bertram Raphael published a formal account of the A* method, which uses a heuristic estimate to guide an algorithm towards the cheapest path. This shows that the two ideas can be combined.

Amos Tversky and Daniel Kahneman introduced the psychological study of judgment heuristics in 1974. Their work presented heuristics as descriptions of how people judge probabilities and frequencies, and as sources of systematic error. Gerd Gigerenzer and Peter Todd later described fast and frugal heuristics in Simple Heuristics That Make Us Smart (1999).

Speed and certainty

Algorithms are often slow because they may require checking many possibilities. A complete search of a game such as chess, for example, would require far more positions than can be examined in a human lifetime. For this reason no practical chess program relies only on exhaustive search, and chess programs combine search with heuristic evaluation.

Heuristics are usually quicker because they consider only a few cues. A person deciding which of two options is more expensive might compare just one feature, such as the price tag, rather than analysing every factor. The result may be correct, but it cannot be guaranteed.

Certainty is the main reason the two strategies are kept apart. A procedure that is guaranteed to find a correct answer is valuable when errors are costly, such as in arithmetic or some engineering tasks. A heuristic is valuable when a fast answer matters more than a perfect one, such as in everyday choices with limited time.

The trade-off can be seen in a simple case. A procedure that tests every combination on a four-digit lock will open it, but it may need up to 10,000 attempts. A shortcut that tries only the combinations a person is most likely to choose is much faster, yet it fails when the code is not one of those guesses. Neither method is wrong; they answer different needs.

Time pressure changes which strategy is sensible. In an emergency, a person who waits for a full procedure may act too late, so a rule that is roughly right and immediate can be the better choice. In a laboratory or an accounting office, where time is less pressing and errors are costly, a full procedure is more appropriate.

Errors and failure

Algorithmic errors usually come from a mistake in the procedure, such as a wrong step, a bad input or an impossible number of steps. These errors can often be traced and corrected, because the procedure is explicit.

Heuristic errors tend to be systematic. Kahneman and Tversky described how availability can make vivid events seem more common, and how anchoring can pull estimates towards an arbitrary number. These errors are predictable because they follow from the shortcut itself.

Not every heuristic error is a bias. Gigerenzer argued that a heuristic can be the best available strategy in an uncertain environment, even when it sometimes produces wrong answers. The question of when heuristic errors reflect poor reasoning is discussed on the questions page on heuristics.

What they have in common

Both algorithms and heuristics are procedures for reaching decisions or solutions. Both can be described as strategies that transform information into an output. Both can be applied to problems with clear goals, such as finding a route, choosing an option or estimating a quantity.

They are also often confused in everyday language. People sometimes call any routine a “formula” or any shortcut an “algorithm”, even when the procedure is not guaranteed to work. Psychologists use the terms more precisely: an algorithm is defined by its guarantee of correctness, and a heuristic by its use of shortcuts.

Researchers in both fields also share a question: how a strategy should be judged. A procedure can be checked by proof that it always reaches the right answer, while a heuristic is usually judged by how often it succeeds across a range of cases. This difference in standards is one reason the two terms are often discussed side by side.

The two ideas meet in computing. Many modern search and optimisation methods are heuristic algorithms, meaning procedures with a fixed set of steps that rely on heuristic rules to guide the search. This hybrid shows that the distinction is useful but not always sharp.

How to tell them apart

A simple test is to ask whether a procedure is guaranteed to produce the correct answer if it is carried out fully. If it is, the method is an algorithm. If the method relies on a rule that usually works but can fail, it is a heuristic.

A second test is to ask what happens when the problem is large. An algorithm may become too slow to use, while a heuristic continues to produce an answer quickly. In that case the heuristic may be the only practical method, even though it is less reliable.

For students, the heuristics hub gives a fuller account of the psychological side, and the list of cognitive biases shows how heuristic errors appear across different kinds of judgment.

Frequently asked questions

What is the difference between a heuristic and an algorithm?

An algorithm is a fixed procedure that reaches a correct answer when it is carried out properly. A heuristic is a rule of thumb that gives a good answer quickly but cannot guarantee that the answer is correct.

Is a heuristic always worse than an algorithm?

No. When an algorithm would need too many steps or too much information, a heuristic can be the only practical option. Researchers such as Gigerenzer argue that simple heuristics can be as accurate as complex procedures in some environments.

What is an example of an algorithm?

Trying every possible combination on a lock with a known number of digits is an algorithm, because it is guaranteed to find the code. It is also slow when there are many combinations. Long division is another example of a procedure with a fixed set of steps.

What is an example of a heuristic in computing?

The A* search algorithm uses a heuristic function to estimate the remaining cost of a route and so explores the most promising paths first. Hart, Nilsson and Raphael described the method in 1968. It finds the shortest path when the heuristic meets certain conditions.

Why do people use heuristics instead of algorithms?

Most everyday problems involve limited time, limited information or too many options for a full analysis. Psychologists explain that the mind relies on heuristics for these reasons, and that the shortcuts are often sufficient for the purpose.

Sources and further reading

  • Peter E. Hart, Nils J. Nilsson and Bertram Raphael, "A Formal Basis for the Heuristic Determination of Minimum Cost Paths", IEEE Transactions on Systems Science and Cybernetics (1968)
  • Judea Pearl, "Heuristics: Intelligent Search Strategies for Computer Problem Solving" (1984)
  • Daniel Kahneman, "Thinking, Fast and Slow" (2011)
  • Gerd Gigerenzer and Peter Todd, "Simple Heuristics That Make Us Smart" (1999)

Cite this page

“Heuristic vs Algorithm: Two Ways to Solve Problems Compared.” Mind & Meaning, https://mind.bigworldlist.com/compare/heuristic-vs-algorithm/.

More about Heuristics