Heuristic Methods in AI: Definition, Uses & Examples

Instructor: Natalie Boyd

Natalie is a teacher and holds an MA in English Education and is in progress on her PhD in psychology.

Artificial intelligence allows computers to solve problems. What happens when there is no solution or finding a solution takes too long? We'll look at heuristic methods in AI and how they can be used to find approximate solutions to complex problems.


Andi is taking a class in artificial intelligence or AI, which is a broad category that involves teaching computers to 'think' and 'learn' using algorithms. Of course, Andi realizes that computers don't really think and learn in the same way that humans do, but she's noticed that a lot of concepts in AI come from the study of the human mind. Most recently, her professor has been talking about heuristics. Andi isn't sure what they are or how they relate to computers or AI.

Heuristics are shortcuts to solutions. The idea of heuristic methods in AI is based on cognitive science or the study of how humans think. Indeed, humans use heuristics all the time to make decisions and solve problems. Likewise, heuristic algorithms are often used in AI to get a computer to find an approximate solution instead of an exact solution.

To Andi, this seems strange. Isn't the point of computers that they are exact? Why use a heuristic when you can just program the computer to solve the problem without the shortcut? The reason heuristic methods are used in AI is that some problems either can't be solved or require too much time or processing power to be reasonable for solving the problem at hand. For example, if Andi wanted to teach a computer how to play chess, she wouldn't want it to take hours assessing the board to figure out the best move. Instead, she'd want it to quickly decide the best move. A heuristic can shorten the time that the computer has to work on that problem.

To help Andi understand heuristics better, let's take a look at a couple of examples of heuristics.

Nearest Neighbor

In one of her homework assignments, Andi has to write an algorithm to solve what her professor calls the 'traveling salesman problem.' This is a common problem posed in AI, and it goes like this: Imagine that you have a long list of cities and distances between each of the cities. You have to visit all the cities and return home. Write an algorithm to find the most efficient route.

The traveling salesman problem uses different numbers of cities that need to be visited. Andi's professor, for example, gave them a list of 1,000 cities, but that number could have been 10,000 or 100,000. The point is that there's a large number of cities and the computer has to figure out the most efficient route to help the salesperson travel to all of them and then return back to the city s/he started in.

Because there are so many cities on the list, the number of possible solutions to the problem is huge. It would take a long time for a computer to process all the permutations and come up with the most efficient one. Instead, something called the nearest neighbor heuristic is often used. The nearest neighbor heuristic asks the computer to figure out the closest city that hasn't been visited yet by the salesperson and make that the next stop. Essentially, the computer is calculating a route node by node. This means that the nearest neighbor heuristic doesn't consider future moves and therefore isn't optimized, but it is a much quicker way to find a route even if it isn't the most efficient route.

Alpha-Beta Pruning

Andi understands the nearest neighbor heuristic and how it can help with that assignment. But her dream is to create online games where people can try to beat a computer at something like chess. How can heuristic methods help her with that?

To unlock this lesson you must be a Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use

Become a member and start learning now.
Become a Member  Back
What teachers are saying about
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 160 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create An Account