In mathematics and computer , an algorithm is a finite sequence of well-defined instructions, typically used to solve a class of specific problems or to perform a computation.

Algorithms are used as specifications for performing calculations, data processing, automated reasoning, automated decision-making and other tasks.

In contrast, a heuristic is a technique used in problem solving that uses practical methods and/or various estimates in order to produce solutions that may not be optimal but are sufficient given the circumstances.