In psychology, an algorithm is a step-by-step problem-solving procedure that guarantees the correct answer if you follow it exactly. A heuristic is a mental shortcut, or rule of thumb, that usually finds a good answer faster but gives no guarantee. Trying every code on a three-digit lock is an algorithm. Looking for lost keys in the last place you used them is a heuristic. The trade-off is certainty and effort against speed and risk.
The definitions look simple, but two things make the pair confusing. Textbooks use "heuristic" for two different kinds of shortcut. And computer science uses both words in a way that does not match the psychology class. Here is the difference, where the contrast came from, and a test that sorts the usual exam examples.
- The key difference is the guarantee. An algorithm that you apply correctly always reaches the answer. A heuristic can fail.
- The College Board's AP Psychology course description says algorithms attempt "all possible solutions until the correct one is found", and heuristics use "mental shortcuts to make judgments".
- In 1958, Allen Newell, J. C. Shaw and Herbert Simon compared an exhaustive-search algorithm with a heuristic computer program. Their algorithm would have needed "hundreds or even thousands of years" for proofs that the program found in minutes.
- Heuristics are not only a source of errors. Tversky and Kahneman called them "quite useful", and later research found cases where a simple heuristic is more accurate than a complex method.
- In computer science, a heuristic is usually a kind of algorithm. In psychology, the two words are opposites.
The difference in one table
| Algorithm | Heuristic | |
|---|---|---|
| What it is | A fixed procedure, step by step | A shortcut or rule of thumb |
| Correct answer guaranteed? | Yes, if you follow it correctly | No |
| Speed and effort | Often slow, sometimes impractically slow | Usually fast and low effort |
| Typical risk | Takes too long, or no procedure exists | Wrong answers, sometimes systematic errors (biases) |
| Everyday example | Following a recipe exactly | Searching for keys where you last used them |
| AP course description wording | "attempting all possible solutions until the correct one is found" | "using mental shortcuts to make judgments" |
A quick memory aid: an algorithm is a recipe, and a heuristic is a hunch with a reason behind it. The recipe always works, but you must follow every step. The hunch is fast, but it can be wrong.
What an algorithm is
The open textbook Psychology 2e from OpenStax defines an algorithm as "a problem-solving formula that provides you with step-by-step instructions used to achieve a desired outcome". It compares an algorithm to "a recipe with highly detailed instructions that produce the same result every time they are performed." Long multiplication is an algorithm of this type. So is a recipe that you follow exactly.
The AP Psychology course and exam description uses a narrower wording. Its essential knowledge statement 2.2.A.3 says: "Algorithms address problems by attempting all possible solutions until the correct one is found." This describes exhaustive search: you check every possibility in turn, and you cannot miss the answer.
The two definitions look different, but they share one property. If you apply the procedure correctly, you get the correct answer. Sally Walters's open textbook, Psychology (1st Canadian edition), says that algorithms are "a logical set of steps that, if applied correctly, should be accurate." Exhaustive search is one kind of algorithm. A recipe is another kind.
The guarantee has a price. Take a bike lock with three digits. The codes run from 000 to 999, so there are 1,000 possibilities. If you try all of them in order, you will open the lock, but it can take a long time. Now try to unscramble the letters of the word HEURISTIC by exhaustive search. Nine letters with one letter used twice give 181,440 different orders. An algorithm that tests every order will find the word, but no person would do it that way.
What a heuristic is
OpenStax calls a heuristic "a general problem-solving framework" and says you can think of heuristics as "mental shortcuts that are used to solve problems." Its example is a "rule of thumb". A heuristic saves time and energy, but in the textbook's words it "is not always the best method for making a rational decision."
The study of heuristic is older than modern psychology. The mathematician George Pólya described it in How to Solve It (1945; second edition 1957). He called it an old branch of study. Its aim, in his words, is "to study the methods and rules of discovery and invention." He named Descartes and Leibniz as the authors of the most famous attempts to build a system of heuristic.
Pólya also wrote that "heuristic, as an adjective, means 'serving to discover.'" He defined heuristic reasoning as reasoning "not regarded as final and strict but as provisional and plausible only, whose purpose is to discover the solution of the present problem." In other words, a heuristic helps you find an answer. It does not prove that the answer is correct.
When do people use heuristics? OpenStax lists five conditions and cites Pratkanis (1989) for them:
- 1.There is too much information.
- 2.The time to make a decision is limited.
- 3.The decision is unimportant.
- 4.There is very little information to use.
- 5.A suitable heuristic comes to mind at that moment.
Many everyday decisions meet at least one of these conditions.
Where the contrast comes from: the Logic Theorist
A well-known early comparison of the two strategies comes from a computer program. In 1958, Allen Newell, J. C. Shaw and Herbert A. Simon published "Elements of a theory of human problem solving" in Psychological Review. They described the Logic Theorist, or LT, a program that searched for proofs of theorems in symbolic logic. They wanted to show that a program could be a theory of how people solve problems.
The researchers gave LT the first 52 theorems from chapter 2 of Whitehead and Russell's Principia Mathematica, in the original order. LT "succeeded in proving 38 (73%)" of them. About half of the proofs took less than a minute each, and most of the others took one to five minutes.
They also compared LT with the only other methods that had been fully specified for such tasks. These were "simple algorithms that carry out exhaustive searches of all possibilities, substituting 'brute force' for the selective search of LT." The difference was large. Their main alternative algorithm "would require times of the order of hundreds or even thousands of years to prove theorems that LT proves in a few minutes." They concluded that LT's success did not depend on the speed of the computer, "but on the use of heuristic processes like those employed by humans."
LT used several of these heuristics:
- It worked backwards from the theorem it had to prove. This used "information about the goal to rule out large numbers of attempts without actually trying them."
- It tried substitution only in theorems that looked similar to the problem, about 10% of the list.
- It could take the simpler subproblems first.
The authors were also clear about the cost. "There is, of course, no guarantee that it will find a proof," they wrote. LT did not prove 14 of the 52 theorems. Its success also depended on the order in which it received the problems. This is the trade-off that textbooks still teach: the algorithm is certain but too slow, and the heuristic is fast but can fail. The exhaustive search that Newell, Shaw and Simon rejected is close to the AP wording for an algorithm today.
Two kinds of heuristics
The word "heuristic" covers two research traditions, and textbooks often mix them.
Problem-solving heuristics
The first tradition comes from Pólya and from Newell, Shaw and Simon. Here a heuristic is a strategy that narrows a search for a solution. OpenStax gives working backwards as an example: "you begin solving the problem by focusing on the end result." If a wedding starts at 4 p.m. in another city, you start from 4 p.m. and plan back to the time you must leave home. Pólya called working backwards "a common-sense procedure within the reach of everybody." Breaking a task into steps is another problem-solving heuristic in the OpenStax list.
Judgement heuristics
The second tradition comes from Amos Tversky and Daniel Kahneman. Their 1974 paper in Science says that people "rely on a limited number of heuristic principles which reduce the complex tasks of assessing probabilities and predicting values to simpler judgmental operations." The paper names three: representativeness, availability, and adjustment and anchoring.
These heuristics answer a different type of question. They do not search for a solution. They estimate how likely or how frequent something is. The AP course description puts its examples here. Its statement 2.2.A.4 says heuristics can lead to errors when decisions follow "prior expectations or stereotypes (representativeness heuristic)" or the "first or most vivid example that comes to mind (availability heuristic)." Our article on how availability and representativeness differ explains both with exam examples.
A heuristic is not the same as a bias. The heuristic is the method, and the bias is the systematic error that the method can cause. Our list of ten cognitive biases explains the difference between a heuristic and a bias in more detail.
Are algorithms always better?
No. An algorithm is better only when one exists, when you can follow it correctly, and when you have the time. The Logic Theorist shows the problem with the time: a guaranteed method that needs centuries is no use.
Tversky and Kahneman also did not describe heuristics as mistakes. They wrote: "In general, these heuristics are quite useful, but sometimes they lead to severe and systematic errors." Their research studied the errors because the errors show how the shortcuts work.
Gerd Gigerenzer and Wolfgang Gaissmaier went further in a 2011 review in the Annual Review of Psychology. They define heuristics as "efficient cognitive processes, conscious or unconscious, that ignore part of the information." They say the classical view held that heuristic decisions "imply greater errors" than rational ones. In their view, how well a heuristic works "is an empirical rather than an a priori issue." The research they review found that "ignoring part of the information can lead to more accurate judgments than weighting and adding all information, for instance for low predictability and small samples." They call these results less-is-more effects.
This is a position in a research debate, not a settled rule. For the exam, the safe answer is the trade-off: algorithms give accuracy at the cost of time and effort, and heuristics give speed at the cost of a guarantee.
Why computer science uses the words differently
If you search for "algorithm vs heuristic", many results come from programmers, and they can contradict your textbook. An answer that you may find online says that every heuristic is a kind of algorithm. In computer science, that is correct.
In programming, an algorithm is any exact step-by-step procedure. A heuristic algorithm is a procedure that gives up the guarantee of the best answer to save time. The Cornell University open textbook on optimisation says heuristics "produce satisfactory solutions within a reasonable timeframe, especially when exact methods are impractical due to computational constraints." It also says they find "good enough solutions without guaranteeing optimality." A program that plans a delivery route by always driving to the nearest unvisited city is a heuristic, and it is also an algorithm.
In a psychology class, the two words are a contrast. The question is not "is it a list of steps?" The question is "does it guarantee the answer?" Everyday speech adds a third use: people call almost any computer process an algorithm. OpenStax gives search engines and social media feeds as examples. For an exam question about human problem solving, use the guarantee test.
Classifying exam scenarios
Two questions sort most examples:
- 1.If the person follows the method correctly, is a correct answer guaranteed? If yes, it is an algorithm.
- 2.If not, does the person use a shortcut or rule that points to likely answers? If yes, it is a heuristic. If the person tries options without a plan until one works, it is trial and error.
OpenStax lists trial and error as a third strategy, separate from algorithms and heuristics. Its example is a broken printer: you check the ink, then the paper tray, then the connection, until something works.
| Example | Strategy | Why |
|---|---|---|
| You try every code on a three-digit lock, from 000 to 999 | Algorithm | It checks all 1,000 possibilities, so it must succeed |
| You follow a cake recipe exactly | Algorithm | Fixed steps that give the same result each time |
| You solve 345 × 27 with long multiplication | Algorithm | A procedure that always gives the correct product |
| You plan a trip by starting from the time you must arrive | Heuristic (working backwards) | It narrows the plan but guarantees nothing |
| You look for your keys first where you last used them | Heuristic (rule of thumb) | Usually fast, sometimes wrong |
| To unscramble letters, you try common endings such as "-ING" first | Heuristic | It skips most of the possible orders |
| You decide a shy, tidy man who likes order is a librarian, not a farmer | Heuristic (representativeness) | You judge by similarity to a stereotype, not by how many librarians and farmers there are |
| After news of a plane crash, you think flying is very dangerous | Heuristic (availability) | You judge by how easily an example comes to mind |
| You try different fixes on a printer until one works | Trial and error | No fixed order and no rule that points to the likely fix |
The librarian example comes from Tversky and Kahneman's 1974 paper, which describes a man called Steve as "very shy and withdrawn" and a "meek and tidy soul".
Learning the pair
Algorithm and heuristic are a contrast pair: two terms that are easy to confuse. Our guide on how to memorise psychology terminology suggests that you put terms that are easy to confuse in one group. Then test yourself on the group instead of rereading the definitions.
Psychology World is a psychology dictionary with more than 18,000 terms. Look up both terms and the related ones, such as trial and error, the availability heuristic and the representativeness heuristic. Save them to one list. Then study the list as flashcards, as multiple-choice questions once the list has four or more terms, or by typing the answer. A daily word also brings terms back without a search. The home page shows the four steps of the learning loop and what each study mode does.
Frequently asked questions
What is an example of an algorithm in psychology?
A common example is trying every possible combination on a lock until it opens. A three-digit lock has 1,000 codes, so trying them all in order must succeed. Following a recipe exactly and solving a sum with long multiplication are also algorithms, because the steps guarantee the result.
Is trial and error an algorithm or a heuristic?
In OpenStax's Psychology 2e, it is neither. Trial and error is a separate strategy: you try different solutions until one works, with no fixed plan. If you try every possibility in a fixed order, such as every code on a lock, the method becomes an algorithm, because it cannot miss the answer.
Is a heuristic the same as a cognitive bias?
No. A heuristic is a mental shortcut that people use to solve a problem or make a judgement. A bias is a systematic error that a heuristic can cause. The availability heuristic is the method, and overestimating rare but memorable dangers is the bias it can produce.
What are the main types of heuristics?
Psychology uses the word for two groups. Problem-solving heuristics, such as working backwards and breaking a task into steps, narrow the search for a solution. Judgement heuristics, which Tversky and Kahneman described in 1974, estimate probability: representativeness, availability, and adjustment and anchoring.
Which is better, an algorithm or a heuristic?
It depends on the problem. An algorithm is better when one exists and you have time to follow it, because it guarantees the answer. A heuristic is better when the problem is too large or the time is short. Some research finds that simple heuristics can be more accurate than complex methods.
Sources
- 1.Newell, A., Shaw, J. C., & Simon, H. A. (1958). Elements of a theory of human problem solving. Psychological Review, 65(3), 151–166.
- 2.Pólya, G. (1957). How to solve it: A new aspect of mathematical method (2nd ed.; 1st ed. 1945). Princeton University Press.
- 3.Tversky, A., & Kahneman, D. (1974). Judgment under uncertainty: Heuristics and biases. Science, 185(4157), 1124–1131.
- 4.Gigerenzer, G., & Gaissmaier, W. (2011). Heuristic decision making. Annual Review of Psychology, 62, 451–482.
- 5.College Board (2024). AP Psychology course and exam description, Topic 2.2.
- 6.Spielman, R. M., Jenkins, W. J., & Lovett, M. D. (2020). Psychology 2e, 7.3 Problem solving. OpenStax.
- 7.Walters, S. (2020). Psychology, 1st Canadian edition, 8.2 Problem-solving: Heuristics and algorithms. TRU Pressbooks.
- 8.Mi, Z., & Yang, B. (2024). Heuristic algorithms. Cornell University Computational Optimization Open Textbook.