# A difference between a heuristic and an algorithm is

posted Mar 2

An algorithm is the description of an automated solution to a problem . What the algorithm does is precisely defined. The solution may or may not be the best possible, but you know from the beginning what kind of result you will get. The algorithm is implemented using some programming language to obtain (a part of) a program.

Whereas an algorithm is a method that contains a finite set of instructions used to solve a problem. The method has been mathematically or scientifically proven to work for the problem. There are formal methods and tests.

An algorithm is typically deterministic and has been shown to produce an optimal result”

Now, some problems are difficult and you may not be able to get an acceptable solution in an acceptable time. In such cases, you can often get a not too bad solution much quicker, by applying some arbitrary options (educated guess) - that's a heuristic.

“A heuristic has no proof of correctness, often involves random elements, and may not give optimal results.”

A heuristic is still a kind of algorithm, but one that will not explore all possible states of the problem, or will start by exploring the most likely ones.

Heuristic, simply put is an "educated guess". Wikipedia explains it very well. In the end, a "generally accepted" method is taken as an optimal solution to the specified problem.

Typical examples are from games. When writing a chess game program, you can imagine that every possible move is attempted to a certain level of depth and some evaluation function is applied to the board. A heuristic would exclude entire branches that start with obviously bad moves.

In some cases, the best solution is not sought, but rather any solution that conforms to some restriction. A good heuristic would help you find a solution in a short time, but it can also fail to find any if the only solutions are in the states you chose not to try.

110,660 points
12 7 5