Definition
An algorithm is a finite sequence of precise and logically ordered instructions designed to solve a problem or perform a computational task. Each instruction describes an operation that can be carried out, and the complete procedure should lead to a clearly defined result.
Essential Idea
An algorithm describes what steps must be performed and in what order. It does not necessarily specify the programming language or the exact syntax used to implement those steps.
Input And Output
An algorithm may receive zero or more inputs and is designed to produce one or more outputs. For example, a multiplication algorithm receives two numbers and produces their product. Some algorithms, such as procedures that generate a sequence, may begin without externally supplied input.
Instruction Sequence
The order of instructions is important. An algorithm must specify which operation happens first, which operation follows, and under what conditions a different operation should be performed. Changing the order can change the result.
Definiteness
Each instruction must be sufficiently precise that its intended operation is understandable and unambiguous. An instruction such as 'process the numbers properly' is too vague because it does not identify a specific operation.
Finiteness
A conventional algorithm must terminate after a finite number of steps for every valid input within its specified operating conditions. An unlimited sequence of operations without a defined stopping condition does not satisfy the ordinary requirement of a terminating algorithm.
Effectiveness
The operations should be sufficiently basic and executable so that they can actually be carried out. An instruction should not depend on an impossible operation or an undefined procedure.
Correctness
An algorithm must produce the required result for every input covered by its specification. A procedure that works for one example but fails for other valid inputs is not a correct general solution.
Implementation Independence
An algorithm can be represented using natural language, pseudocode, flowcharts, or mathematical descriptions. It can then be implemented in different programming languages without changing its underlying logical method.