In its most general sense, an algorithm is any set of detailed instructions which results in a predictable end-state from a known beginning. Algorithms are only as good as the instructions given, however, and the result will be incorrect if the algorithm is not properly defined.
Examples of Algorithms
A common example of an algorithm would be instructions for assembling a model airplane. Given the starting set of a number of marked pieces, one can follow the instructions given to result in a predictable end-state: the completed airplane. Misprints in the instructions, or a failure to properly follow a step, will result in a faulty end product.
A computer program is another pervasive example. Every computer program is simply a series of instructions, which may vary in complexity, and is listed in a specific order, designed to perform a specific task. Mathematics also uses algorithms to solve equations by hand, without the use of a calculator. One last example is the human brain: most conceptions of the human brain define all behavior — from the acquisition of food to falling in love — as the result of a complex algorithm.
Classes of Algorithms
While there is no universally accepted breakdown for the various types of algorithms, there are common classes that algorithms are frequently agreed to belong to. Among these are:
- Dynamic Programming Algorithms: This class remembers older results and attempts to use this to speed the process of finding new results.
- Greedy Algorithms: Greedy algorithms attempt not only to find a solution, but to find the ideal solution to any given problem.
- Brute Force Algorithms: The brute force approach starts at some random point and iterates through every possibility until it finds the solution.
- Randomized Algorithms: This class includes any algorithm that uses a random number at any point during its process.
- Branch and Bound Algorithms: Branch and bound algorithms form a tree of subproblems to the primary problem, following each branch until it is either solved or lumped in with another branch.
- Simple Recursive Algorithms: This type goes for a direct solution immediately, then backtracks to find a simpler solution.
- Backtracking Algorithms: Backtracking algorithms test for a solution; if a solution is found the algorithm has solved, if not it recurs once and tests again, continuing until a solution is found.
- Divide and Conquer Algorithms: A divide and conquer algorithm is similar to a branch and bound algorithm, except it uses the backtracking method of recurring while dividing a problem into subproblems.
Serial and Parallel Algorithms
In addition to these general classes, algorithms may also be divided into two primary groups: serial algorithms, which are designed for serial execution, wherein each operation is enacted in a linear order; and parallel algorithms, used with computers running parallel processors, wherein a number of operations are run parallel to each other. Parallel algorithms also exist in the natural world in the case of, for example, genetic mutation over a species.