An algorithm, broadly defined, is an understandable and finite set of instructions for accomplishing some task which, given a defined set of inputs, will result in some recognisable end-state (contrast with heuristic). Algorithms often have steps that repeat (iterate) or require decisions (such as logic or comparison) until the task is completed.