An algorithm is a procedure or set of steps to solve a problem in a specific order. It consists of sequence, selection, iteration, and case-type statements. Common iteration statements in algorithms include while, do, and for loops. A computer program can be viewed as an elaborate algorithm, and applying an algorithm to input produces an output through computation.