An algorithm is a finite set of procedural and elementary computational steps to transform a specific set of inputs to a specific set of outputs.
More technically, for a set of inputs and a set of outputs , an algorithm is a function where inputs are mapped to outputs.
Algorithms are designed, analyzed and optimized on the theoretical basis of a model of computation and operate within those specifications.
Key Properties
- Finiteness — must terminate after a finite number of steps
- Definiteness — each step must be precisely defined
- Input — zero or more well-defined inputs
- Output — one or more well-defined outputs
- Effectiveness — each operation must be basic enough to be done exactly in finite time
Complexity Classes
Algorithm efficiency is measured in terms of time and space as functions of input size :
| Notation | Name | Example |
|---|---|---|
| Constant | Array access | |
| Logarithmic | Binary search | |
| Linear | Linear scan | |
| Linearithmic | Merge sort | |
| Quadratic | Bubble sort | |
| Exponential | Subset enumeration |
Related
- Computational Problem — what algorithms solve
- RAM Model of Computation — the abstract machine algorithms run on
- Data Structure — how algorithms organize their working data