An algorithm is a defined set of step-by-step instructions that a computer follows to solve a problem or turn input into output.