An algorithm is “any well-defined computational procedure that takes … input and produces … output in a finite amount of time” (@cormenIntroductionAlgorithms2022). An algorithm is an abstract version of a program, i.e. it can be discussed in pseudocode.

An algorithm is correct if it can finish computing the correct solution for a computational problem (i.e. it halts) for all valid inputs. This does not mean that only correct algorithms are useful—we can take advantage of “incorrect” ones if the errors are kept in control.