In its most general sense, an algorithm is any set of detailed instructions that result in a predictable end state from a known start. However, algorithms are only as good as the instructions given and the result will be wrong if the algorithm is not defined correctly.
An algorithm in a computer program.
Algorithm Examples
A common example of an algorithm would be the instructions for building a model airplane. Given the initial set of various marked parts, the instructions provided can be followed to obtain a predictable final state: the complete plane. Misprints in instructions or not following a step correctly will result in a defective end product.
The concept of falling in love can be described as the result of a complex algorithm.
A computer program is another generalized example. Each computer program is simply a series of instructions, which can vary in complexity and are listed in a specific order, designed to perform a specific task. Mathematics also uses algorithms to solve equations manually, without the use of a calculator. A final example is the human brain: most conceptions of the human brain define all behavior, from food acquisition to falling in love, as the result of a complex algorithm.
Algorithm classes
While there is no universally accepted division for the various types of algorithms, there are common classes to which algorithms often accept membership. Among them are:
Dynamic Programming Algorithms: This class remembers previous results and tries to use them to speed up the process of finding new results.
Greedy Algorithms: Greedy algorithms try to find not only one solution, but also the optimal solution to any problem.
Brute Force Algorithms: The brute force approach starts at some random point and iterates through all possibilities until the solution is found.
Random Algorithms: This class includes any algorithm that uses a random number at any point during its process.
Branch and Limit Algorithms: Branch and limit algorithms form a tree of subproblems for the main problem, following each branch until it is solved or grouped with another branch.
Simple recursive algorithms: This type goes to a direct solution right away, then backtracks to find a simpler solution.
Backtracking Algorithms: Test Backtracking Algorithms for a Solution; if a solution is found, the algorithm has solved it, otherwise it loops once and tries 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 that it uses the recursion backtracking method when dividing a problem into subproblems.
Serial and Parallel Algorithms
In addition to these general classes, algorithms can also be divided into two main groups: serial algorithms, which are designed for serial execution, where each operation is performed in a linear order; and parallel algorithms, used with computers running parallel processors, where a series of operations are performed in parallel with each other. Parallel algorithms also exist in the natural world in the case of, say, a genetic mutation in a species.