An algorithm is a finite, well-defined sequence of steps that transforms input into the desired output. We judge it on two axes: correctness (does it always produce the right answer?) and efficiency (how much time and memory does it use?).
The idea
A valid algorithm must be (each step is clear), (it terminates), and produce the result for every valid input.
