An algorithm is a finite sequence of well-defined instructions, typically used to solve a class of specific problems or perform a computation. Algorithms are used as specifications for performing calculations, data processing, automated reasoning, automated decision-making, and other tasks. A heuristic, in contrast, is an approach to problem-solving that may not be fully specified or may not guarantee correct or optimal results, especially in problem domains where there is no well-defined correct or optimal result.