AllExperts > Encyclopedia 
Search      
Find out about volunteering to AllExperts

Algorithm: Encyclopedia BETA


Free Encyclopedia
 Index · Browse A-Z  · Questions and Answers ·
Encyclopedia

Browse A-Z
ABCDEFGHIJKLMNOPQRSTUVWXYZNum


License
Disclaimer

 
 
 
 
Free Online Courses
12 Weeks to Weight Loss
Take Charge of Stress
Learn How to Bake
Budgeting 101
Deeper Faith
DIY Fashion Makeover

       MORE E-COURSES
 
   

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z  Misc

Algorithm

Flowchart.png

Flowcharts are often used to graphically represent algorithms.

In mathematics and computing, an algorithm is a procedure (a finite set of well-defined instructions) for accomplishing some task which, given an initial state, will terminate in a defined end-state. The computational complexity and efficient implementation of the algorithm are important in computing, and this depends on suitable data structures.

Informally, the concept of an algorithm is often illustrated by the example of a recipe, although many algorithms are much more complex; algorithms often have steps that repeat (iterate) or require decisions (such as logic or comparison). Algorithms can be composed to create more complex algorithms.

The concept of an algorithm originated as a means of recording procedures for solving mathematical problems such as finding the common divisor of two numbers or multiplying two numbers. The concept was formalized in 1936 through Alan Turing's Turing machines and Alonzo Church's lambda calculus, which in turn formed the foundation of computer science.

Most algorithms can be directly implemented by computer programs; any other algorithms can at least in theory be simulated by computer programs. In many programming languages, algorithms are implemented as functions or procedures.

History

Origin of the word

The word algorithm comes from the name of the 9th century Persian mathematician Abu Abdullah Muhammad ibn Musa al-Khwarizmi. The word algorism originally referred only to the rules of performing arithmetic using Hindu-Arabic numerals but evolved via European Latin translation of al-Khwarizmi's name into algorithm by the 18th century. The word evolved to include all definite procedures for solving problems or performing tasks.

Discrete and distinguishable symbols

Tally-marks: To keep track of their flocks, their sacks of grain and their money the ancients used tallying â€" accumulating stones, or marks -- discrete symbols in clay or scratched on sticks. Through the Babylonians and Egyptian use of marks and symbols eventually Roman numerals and the abacus evolved. (Dilson, p.16-41) Tally marks appear prominently in unary numeral system arithmetic used in Turing machine and Post-Turing machine computations.

Mechanical contrivances with discrete states

The clock: Bolter credits the invention of the weight-driven clock as "The key invention [of Europe in the Middle ages]", in particular the verge escapement (Bolter p. 24) that provides us with the tick and tock of a mechanical clock. "The accurate automatic machine" (Bolter quoting Mumford cf Bolton p. 26) led immediately to "mechanical automata" beginning in the thirteenth century and finally to "computational machines" â€" the difference engine and analytical engines of Charles Babbage and Countess Ada Lovelace (p.33-34, p.204-206).

Jacquard loom, Hollerith punch cards, telegraphy and telephony -- the electromechanical relay: Bell and Newell (1971) indicate that the Jacquard loom (1801), precursor to Hollerith cards (punch cards, 1887), and "telephone switching technologies" were the roots of a tree leading to the development of the first computers (Bell and Newell diagram p. 39, cf Davis (2000)). By the mid-1800's the telegraph, as the precursor of the telephone, was in use throughout the world, its discrete and distinguishable encoding of letters as "dots and dashes" a common sound. By the late 1800's the ticker tape (ca 1870's) was in use, as were the use of Hollerith cards in the 1890 U.S. census, the Teletype (ca 1910) with its the use of punched-paper binary encoding Baudot code on tape.

Telephone-switching networks of electromechanical relays (invented 1835) was behind the work of George Stibitz (1937), the inventor of the digital adding device. As he worked in Bell Laboratories, he observed the "burdensome' use of mechanical calculators with gears. "He went home one evening in 1937 intending to test his idea.... When the tinkering was over, Stibitz had constructed a binary adding device" (Valley News, p. 13).

Davis (2000) observes the particular importance of the electromechanical relay (with its two "binary states" open and closed):: It was a only with the development, beginning in the 1930's, of electromechanical calculators using electrical relays, that machines were built having the scope Babbage had envisioned." (Davis, p. 148)

Mathematics during the 1800's up to the mid-1900's

Symbols and rules: In rapid succession the mathematics of George Boole (1847, 1854), Gottlob Frege (1879), and Giuseppe Peano (1888-9) reduced arithmetic to a sequence of symbols manipulated by rules. Peano's The principles of arithmetic, presented by a new method (1888) was "the first attempt at an axiomatization of mathematics in a symbolic language" (Heijenoort, p. 81ff).

But Heijenoort gives Frege (1879) this kudos: Frege's is "perhaps the most important single work ever written in logic. ... in which we see a " 'formula language', that is a lingua characterica, a language written with special symbols, "for pure thought", that is, free from rhetorical embellishments ... constructed from specific symbols that are manipulated according to definite rules"( p. 1). The work of Frege was further simplified and amplified by Alfred North Whitehead and Bertrand Russell in their Principia Mathematica (1910-1913).

The paradoxes: At the same time a number of disturbing paradoxes appeared in the literature, in particular the Burali-Forti paradox (1897), the Russell paradox (1902-03), and the Richard Paradox (1905, Dixon 1906), (cf Kleene (1952) p. 36-40). The resultant considerations led to Kurt Gödel's paper (1931) that completely reduces rules of recursion to numbers. In rapid succession the following appeared: Church-Kleene's λ-calculus (cf footnote in Alonzo Church's paper, Undecidable p. 90), Church's (1936) theorem (Undecidable, p. 88ff), Emil Post's (1936) "process" (Undecidable, p. 289-290), Alan Turing's (1936-1937) "a- [automatic-] machine" (Undecidable, p. 116ff), J. Barkley Rosser's (1939) definition of "effective method" in terms of "a machine" (Undecidable, p. 226), and S. C. Kleene's (1943) proposal of the "Church-Turing thesis" (Undecidable, p. 273-274)

Emil Post (1936) and Alan Turing (1936, 1937)

Here is a remarkable coincidence of two men not knowing one another but describing a process of men-as-computers working on computations -- and they yield virtually identical definitions.

Emil Post (1936) described the actions of a "computer" (a man) as follows: :"...two concepts are involved: that of a symbol space in which the work leading from problem to answer is to be carried out, and a fixed unalterable set of directions.

His symbol space would be :"a two way infinite sequence of spaces or boxes... The problem solver or worker is to move and work in this symbol space, being capable of being in, and operating in but one box at a time.... a box is to admit of but two possible conditions, i.e. being empty or unmarked, and having a single mark in it, say a vertical stroke.

"One box is to be singled out and called the starting point. ...a specific problem is to be given in symbolic form by a finite number of boxes [i.e. INPUT] being marked with a stroke. Likewise the answer [i.e. OUTPUT] is to be given in symbolic form by such a configuration of marked boxes....

"A set of directions applicable to a general problem sets up a deterministic process when applied to each specific problem. This process will terminate only when it comes to the direction of type (C ) [i.e. STOP]." (U p. 289-290) See more at Post-Turing machine

Alan Turing's work (1936-1937) preceded that of Stibitz (1937); it is unknown if Stibitz knew of the work of Turing. Turing's biographer believed that Turing's use of a typewriter-like model derived from a youthful interest: "Alan had dreamt of inventing typewriters as a boy; Mrs. Turing had a typewriter; and he could well have begun by asking himself what was meant by calling a typewriter 'mechanical'" (Hodges, p. 96) Given the prevalence of Morse code and telegraphy, ticker tape machines, and Teletypes we might conjecture that all were influences.

Turing begins, as did Post, with an analysis of a human computer that he whittles down to a simple set of basic motions and "states of mind". But he continues a step further and creates his machine as a model of computation of numbers (Undecidable p. 116):

"Computing is normally done by writing certain symbols on paper. We may suppose this paper is divided into squares like a child's arithmetic book....I assume then that the computation is carried out on one-dimensional paper, i.e. on a tape divided into squares. I shall also suppose that the number of symbols which may be printed is finite....

"The behavior of the computer at any moment is determined by the symbols which he is observing, and his "state of mind" at that moment. We may suppose that there is a bound B to the number of symbols or squares which the computer can observe at one moment. If he wishes to observe more, he must use successive observations. We will also suppose that the number of states of mind which need be taken into account is finite...

"Let us imagine that the operations performed by the computer to be split up into 'simple operations' which are so elementary that it is not easy to imagine them further divided" (Undecidable p. 136).

Turing's reduction yields the following:

"The simple operations must therefore include: ::"(a) Changes of the symbol on one of the observed squares ::"(b) Changes of one of the squares observed to another square within L squares of one of the previously observed squares."It may be that some of these change necessarily invoke a change of state of mind. The most general single operation must therefore be taken to be one of the following: ::"(A) A possible change (a) of symbol together with a possible change of state of mind. ::"(B) A possible change (b) of observed squares, together with a possible change of state of mind"

"We may now construct a machine to do the work of this computer."(Undecidable p. 137)

J. B. Rosser (1939) and S. C. Kleene (1943)

J. Barkley Rosser boldly defined an ‘effective [mathematical] method' in the following manner (boldface added)::"'Effective method' is used here in the rather special sense of a method each step of which is precisely determined and which is certain to produce the answer in a finite number of steps. With this special meaning, three different precise definitions have been given to date. [his footnote #5; see discussion immediately below]. The simplest of these to state (due to Post and Turing) says essentially that an effective method of solving certain sets of problems exists if one can build a machine which will then solve any problem of the set with no human intervention beyond inserting the question and (later) reading the answer. All three definitions are equivalent, so it doesn't matter which one is used. Moreover, the fact that all three are equivalent is a very strong argument for the correctness of any one. (Undecidable, p. 225-226)

Rosser's footnote #5 references the work of (1) Church and Kleene and their definition of λ-definability, in particular Church's use of it in his An Unsolvable Problem of Elementary Number Theory (1936); (2) Herbrand and Gödel and their use of recursion in particular Gödel's use in his famous paper On Formally Undecidable Propostions of Principia Mathematica and Related Systems I (1931); and (3) Post and Turing in their mechanism-models of computation.

Stephen C. Kleene (1943) defined as his now-famous "Thesis I" known as "the Church-Turing Thesis". But he did this in the following context (boldface in original)::"12. Algorithmic theories... In setting up a complete algorithmic theory, what we do is to describe a procedure, performable for each set of values of the independent variables, which procedure necessarily terminates and in such manner that from the outcome we can read a definite answer, "yes" or "no," to the question, "is the predicate value true?"" (the Undecidable, p. 273)

Formalization of algorithms

Algorithms are essential to the way computers process information, because a computer program is essentially an algorithm that tells the computer what specific steps to perform (in what specific order) in order to carry out a specified task, such as calculating employees' paychecks or printing students' report cards. Thus, an algorithm can be considered to be any sequence of operations which can be performed by a Turing-complete system. Authors who assert this thesis include Savage (1987) and Gurevich (2000):

"...Turing's informal argument in favor of his thesis justifies a stronger thesis: every algorithm can be simulated by a Turing machine" (Gurevich 2000 p.1) ...according to Savage [1987], an algorithm is a computational process defined by a Turing machine."(Gurevich 2000 p.3)

Typically, when an algorithm is associated with processing information, data is read from an input source or device, written to an output sink or device, and/or stored for further processing. Stored data is regarded as part of the internal state of the entity performing the algorithm. In practice, the state is stored in a data structure, but an algorithm requires the internal data only for specific operation sets called abstract data types.

For any such computational process, the algorithm must be rigorously defined: specified in the way it applies in all possible circumstances that could arise. That is, any conditional steps must be systematically dealt with, case-by-case; the criteria for each case must be clear (and computable).

Because an algorithm is a precise list of precise steps, the order of computation will almost always be critical to the functioning of the algorithm. Instructions are usually assumed to be listed explicitly, and are described as starting 'from the top' and going 'down to the bottom', an idea that is described more formally by flow of control.

So far, this discussion of the formalization of an algorithm has assumed the premises of imperative programming. This is the most common conception, and it attempts to describe a task in discrete, 'mechanical' means. Unique to this conception of formalized algorithms is the assignment operation, setting the value of a variable. It derives from the intuition of 'memory' as a scratchpad. There is an example below of such an assignment.

See functional programming and logic programming for alternate conceptions of what constitutes an algorithm.

Some writers restrict the definition of algorithm to procedures that eventually finish. In such a category Kleene 1952 places the "decision procedure or decision method or algorithm for the question" (Kleene p. 136). Others, including Kleene, include procedures that could run forever without stopping; such a procedure has been called a "computational method" (Knuth, Vol.1 p. 5) or "calculation procedure or algorithm" (Kleene p. 137); however, Kleene notes that such a method must eventually exhibit "some object" (Kleene p. 137). In the latter case (computation method, calculation procedure) success can no longer be defined in terms of halting with a meaningful output. Instead, terms of success that allow for unbounded output sequences must be defined. For example, an algorithm that verifies if there are more zeros than ones in an infinite random binary sequence must run forever to be effective. If it is implemented correctly, however, the algorithm's output will be useful: for as long as it examines the sequence, the algorithm will give a positive response while the number of examined zeros outnumber the ones, and a negative response otherwise. Success for this algorithm could then be defined as eventually outputting only positive responses if there are actually more zeros than ones in the sequence, and in any other case outputting any mixture of positive and negative responses.

A. A. Markov's characterization

A. A. Markov (1954) provided the following definition of algorithm:
:"1. In mathematics, "algorithm" is commonly understood to be an exact prescription, defining a computational process, leading from various initial data to the desired result...."

"The following three features are characteristic of algorithms and determine their role in mathematics:::"a) the precision of the prescription, leaving no place to arbitrariness, and its universal comprehensibility -- the definiteness of the algorithm;::"b) the possibility of starting out with initial data, which may vary within given limits -- the generality of the algorithm;::"c) the orientation of the algorithm toward obtaining some desired result, which is indeed obtained in the end with proper initial data -- the conclusiveness of the algorithm." (p.1)

He admitted that this definition "does not pretend to mathematical precision" (p. 1). His 1954 monograph was his attempt to define algorithm more accurately; he saw his resulting definition as "equivalent to the concept of a recursive function" (p. 3). His definition included four major components (Chapter II.3 pp.63ff):

"1. Separate elementary steps, each of which will be performed according to one of [the substitution] rules... [rules given at the outset]

"2. ... steps of local nature ... [Thus the algorithm won't change more than a certain number of symbols to the left or right of the observed word/symbol ]

"3. Rules for the substitution formulas ... [he called the list of these "the scheme" of the algorithm]

"4. ...a means to distinguish a "concluding substitution" [i.e. a distinguishable "terminal/final" state or states]

In his Introduction Markov observed that "the entire significance for mathematics" of efforts to define algorithm more precisely would be "in connection with the problem of a constructive foundation for mathematics" (p. 2). Ian Stewart shares a similar belief: "...constructive analysis is very much in the same algorithmic spirit as computer science...". For more see constructive mathematics and Intuitionism.

The notion of "locality" first appeared with Turing (1936-1937) -- "Changes of one of the squares observed to another square within L squares of one of the previously observed squares", and it appears prominently in the work of Gurevich.

Knuth's characterization

Knuth (1968, 1973) has given a list of five properties that are widely accepted as requirements for an algorithm:

# Finiteness: "An algorithm must always terminate after a finite number of steps"# Definiteness: "Each step of an algorithm must be precisely defined; the actions to be carried out must be rigorously and unambiguously specified for each case"# Input: "...quantities which are given to it initially before the algorithm begins. These inputs are taken from specified sets of objects"# Output: "...quantities which have a specified relation to the inputs"# Effectiveness: "... all of the operations to be performed in the algorithm must be sufficiently basic that they can in principle be done exactly and in a finite length of time by a man using paper and pencil"

The Euclidean algorithm for determining the greatest common divisor of two natural numbers is an example of such an algorithm.

Knuth admits this description of an algorithm is intuitively clear but lacks formal rigor, since it is not exactly clear what "precisely defined" means, or "rigorously and unambiguously specified" means, or "sufficiently basic", and so forth.

Stone's characterization

Stone (1972) and Knuth (1968, 1973) were professors at Stanford University at the same time so it is not surprising if there are similarities in their definitions:

"To summarize ... we define an algorithm to be a set of rules that precisely defines a sequence of operations such that each rule is effective and definite and such that the sequence terminates in a finite time." (boldface added, p. 8)

Stone is noteworthy because of his detailed discussion of what constitutes an "effective" rule â€" his robot, or person-acting-as-robot, must have some information and abilities within them, and if not the information and the ability must be provided in "the algorithm":

"For people to follow the rules of an algorithm, the rules must be formulated so that they can be followed in a robot-like manner, that is, without the need for thought... however, if the instructions [to solve the quadratic equation, his example] are to be obeyed by someone who knows how to perform arithmetic operations but does not know how to extract a square root, then we must also provide a set of rules for extracting a square root in order to satisfy the definition of algorithm" (p. 4-5)

Furthermore "...not all instructions are acceptable, because they may require the robot to have abilities beyond those that we consider reasonable." He gives the example of a robot confronted with the question is "Henry VIII a King of England?" and to print 1 if yes and 0 if no, but the robot has not been previously provided with this information. And worse, if the robot is asked if Aristotle was a King of England and the robot only had been provided with five names, it would not know how to answer. Thus "an intuitive definition of an acceptable sequence of instructions is one in which each instruction is precisely defined so that the robot is guaranteed to be able to obey it" (p. 6)

After providing us with his definition, Stone introduces the Turing machine model and states that the set of five-tupes that are the machine's instructions are "an algorithm ... known as a Turing machine program" (p. 9). Immediately thereafter he goes on say that a "computation of a Turing machine is described by stating::"1. The tape alphabet :"2. The form in which the parameters are presented on the tape :"3. The initial state of the Turing machine :"4. The form in which answers will be represented on the tape when the Turing machine halts :"5. The machine program" (italics added, p. 10)

This precise prescription of what is required for "a computation" is in the spirit of what will follow in the work of Blass and Gurevich.

Blass and Gurevich's characterization

Blass and Gurevich describe their work as evolved from consideration of Turing machines, Kolmogorov-Uspensky machines (KU machines), Schönhage machine (storage modification machine SMM), and pointer machines (linking automata) as defined by Knuth. The work of Gandy and Markov are also described as influential precursors.

Gurevich offers a 'strong' definition of an algorithm (boldface added):

"...Turing's informal argument in favor of his thesis justifies a stronger thesis: every algorithm can be simulated by a Turing machine....In practice, it would be ridiculous...[Nevertheless,] [c]an one generalize Turing machines so that any algorithm, never mind how abstract, can be modeled by a generalized machine?...But suppose such generalized Turing machines exist. What would their states be?...a first-order structure ... a particular small instruction set suffices in all cases ... computation as an evolution of the state ... could be nondeterministic... can interact with their environment ... [could be] parallel and multi-agent ... [could have] dynamic semantics ... [the two underpinings of thier work are:] Turing's thesis ...[and] the notion of (first order) structure of [Tarski 1933]" (Gurevich 2000, p. 1-2)

The above phrase computation as an evolution of the state differs markedly from the definition of Knuth and Stone and includes both the current instruction (state) and the status of the tape. [cf Kleene (1952) p. 375 where he shows an example of a tape with 6 symbols on it and how to Gödelize its combined table-tape status].

Expressing algorithms

Algorithms can be expressed in many kinds of notation, including natural languages, pseudocode, flowcharts, and programming languages. Natural language expressions of algorithms tend to be verbose and ambiguous, and are rarely used for complex or technical algorithms. Pseudocode and flowcharts are structured ways to express algorithms that avoid many of the ambiguities common in natural language statements, while remaining independent of a particular implementation language. Programming languages are primarily intended for expressing algorithms in a form that can be executed by a computer, but are often used as a way to define or document algorithms.

Implementation

Most algorithms are intended to be implemented as computer programs. However, algorithms are also implemented by other means, such as in a biological neural network (for example, the human brain implementing arithmetic or an insect relocating food), in electric circuits, or in a mechanical device.

Examples

One of the simplest algorithms is to find the largest number in an (unsorted) list of numbers. The solution necessarily requires looking at every number in the list, but only once at each. From this follows a simple algorithm, which can be stated in English as:

# Assume the first item is largest.# Look at each of the remaining items in the list and if it is larger than the largest item so far, make a note of it.# The last noted item is the largest in the list when the process is complete.

Here is a more formal coding of the algorithm in pseudocode:

Input: A non-empty list of numbers L. Output: The largest number in the list L.
largest ← L0 for each item in the list L≄1, do if the item > largest, then largest ← the item return largest

For a more complex example of an algorithm, see Euclid's algorithm, which is one of the oldest algorithms.

Algorithm analysis

As it happens, most people who implement algorithms want to know how much of a particular resource (such as time or storage) is required for a given algorithm. Methods have been developed for the analysis of algorithms to obtain such quantitative answers; for example, the algorithm above has a time requirement of O(n), using the big O notation with n as the length of the list. At all times the algorithm only needs to remember two values: the largest number found so far, and its current position in the input list. Therefore it is said to have a space requirement of O(1)In this example the sizes of the numbers themselves could be unbounded and one could therefore argue that the space requirement is O(log n). In practice, however, the numbers considered would be bounded and hence the space taken up each number is fixed.. (Note that the size of the inputs is not counted as space used by the algorithm.)

Different algorithms may complete the same task with a different set of instructions in less or more time, space, or effort than others. For example, given two different recipes for making potato salad, one may have peel the potato before boil the potato while the other presents the steps in the reverse order, yet they both call for these steps to be repeated for all potatoes and end when the potato salad is ready to be eaten.

The analysis and study of algorithms is one discipline of computer science, and is often practiced abstractly (without the use of a specific programming language or other implementation). In this sense, it resembles other mathematical disciplines in that the analysis focuses on the underlying principles of the algorithm, and not on any particular implementation. The pseudocode is simplest and abstract enough for such analysis.

Classes

There are various ways to classify algorithms, each with its own merits.

Classification by implementation

One way to classify algorithms is by implementation means.
* Recursion or iteration: A recursive algorithm is one that invokes (makes reference to) itself repeatedly until a certain condition matches, which is a method common to functional programming. Iterative algorithms use repetitive constructs like loops and sometimes additional data structures like stacks to solve the given problems. Some problems are naturally suited for one implementation or the other. For example, towers of hanoi is well understood in recursive implementation. Every recursive version has an equivalent (but possibly more or less complex) iterative version, and vice versa.
* Logical: An algorithm may be viewed as controlled logical deduction. This notion may be expressed as:
Algorithm = logic + control.
The logic component expresses the axioms which may be used in the computation and the control component determines the way in which deduction is applied to the axioms. This is the basis for the logic programming paradigm. In pure logic programming languages the control component is fixed and algorithms are specified by supplying only the logic component. The appeal of this approach is the elegant semantics: a change in the axioms has a well defined change in the algorithm.
* Serial or parallel: Algorithms are usually discussed with the assumption that computers execute one instruction of an algorithm at a time. Those computers are sometimes called serial computers. An algorithm designed for such an environment is called a serial algorithm, as opposed to parallel algorithms, which take advantage of computer architectures where several processors can work on a problem at the same time. Parallel algorithms divide the problem into more symmetrical or asymmetrical subproblems and pass them to many processors and put the results back together at one end. The resource consumption in parallel algorithms is both processor cycles on each processor and also the communication overhead between the processors. Sorting algorithms can be parallelized efficiently, but their communication overhead is expensive. Recursive algorithms are generally parallelizable. Some problems have no parallel algorithms, and are called inherently serial problems. Those problems cannot be solved faster by employing more processors. Iterative numerical methods, such as Newton's method or the three body problem, are algorithms which are inherently serial.
* Deterministic or random: Deterministic algorithms solve the problem with exact decision at every step of the algorithm. Randomized algorithms as their name suggests explore the search space randomly until an acceptable solution is found. Various heuristic algorithms (see below) generally fall into the random category.
* Exact or approximate: While many algorithms reach an exact solution, approximation algorithms seek an approximation which is close to the true solution. Approximation may use either a deterministic or a random strategy. Such algorithms have practical value for many hard problems.

Classification by design paradigm

Another way of classifying algorithms is by their design methodology or paradigm. There is a certain number of paradigms, each different from the other. Furthermore, each of these categories will include many different types of algorithms. Some commonly found paradigms include:
* Divide and conquer. A divide and conquer algorithm repeatedly reduces an instance of a problem to one or more smaller instances of the same problem (usually recursively), until the instances are small enough to solve easily. One such example of divide and conquer is merge sorting. Sorting can be done on each segment of data after dividing data into segments and sorting of entire data can be obtained in conquer phase by merging them. A simpler variant of divide and conquer is called decrease and conquer algorithm, that solves an identical subproblem and uses the solution of this subproblem to solve the bigger problem. Divide and conquer divides the problem into multiple subproblems and so conquer stage will be more complex than decrease and conquer algorithms. An example of decrease and conquer algorithm is binary search algorithm.
* Dynamic programming. When a problem shows optimal substructure, meaning the optimal solution to a problem can be constructed from optimal solutions to subproblems, and overlapping subproblems, meaning the same subproblems are used to solve many different problem instances, we can often solve the problem quickly using dynamic programming, an approach that avoids recomputing solutions that have already been computed. For example, the shortest path to a goal from a vertex in a weighted graph can be found by using the shortest path to the goal from all adjacent vertices. Dynamic programming and memoization go together. The main difference between dynamic programming and divide and conquer is, subproblems are more or less independent in divide and conquer, where as the overlap of subproblems occur in dynamic programming. The difference between the dynamic programming and straightforward recursion is in caching or memoization of recursive calls. Where subproblems are independent, there is no chance of repetition and memoization does not help, so dynamic programming is not a solution for all. By using memoization or maintaining a table of subproblems already solved, dynamic programming reduces the exponential nature of many problems to polynomial complexity.
* The greedy method. A greedy algorithm is similar to a dynamic programming algorithm, but the difference is that solutions to the subproblems do not have to be known at each stage; instead a "greedy" choice can be made of what looks best for the moment. The difference between dynamic programming and the greedy method is, it extends the solution with the best possible decision (not all feasible decisions) at an algorithmic stage based on the current local optimum and the best decision (not all possible decisions) made in previous stage. It is not exhaustive, and does not give accurate answer to many problems. But when it works, it will be the fastest method. The most popular greedy algorithm is finding the minimal spanning tree as given by Kruskal.
* Linear programming. When solving a problem using linear programming, the program is put into a number of linear inequalities and then an attempt is made to maximize (or minimize) the inputs. Many problems (such as the maximum flow for directed graphs) can be stated in a linear programming way, and then be solved by a 'generic' algorithm such as the simplex algorithm. A complex variant of linear programming is called integer programming, where the solution space is restricted to all integers.
* Reduction. This is another powerful technique in solving many problems by transforming one problem into another problem. For example, one selection algorithm for finding the median in an unsorted list is first translating this problem into sorting problem and finding the middle element in sorted list. The goal of reduction algorithms is finding the simplest transformation such that complexity of reduction algorithm does not dominate the complexity of reduced algorithm. This technique is also called transform and conquer.
* Search and enumeration. Many problems (such as playing chess) can be modeled as problems on graphs. A graph exploration algorithm specifies rules for moving around a graph and is useful for such problems. This category also includes the search algorithms and backtracking.
* The probabilistic and heuristic paradigm. Algorithms belonging to this class fit the definition of an algorithm more loosely. # Probabilistic algorithms are those that make some choices randomly (or pseudo-randomly); for some problems, it can in fact be proven that the fastest solutions must involve some randomness. # Genetic algorithms attempt to find solutions to problems by mimicking biological evolutionary processes, with a cycle of random mutations yielding successive generations of "solutions". Thus, they emulate reproduction and "survival of the fittest". In genetic programming, this approach is extended to algorithms, by regarding the algorithm itself as a "solution" to a problem. Also there are # Heuristic algorithms, whose general purpose is not to find an optimal solution, but an approximate solution where the time or resources to find a perfect solution are not practical. An example of this would be local search, taboo search, or simulated annealing algorithms, a class of heuristic probabilistic algorithms that vary the solution of a problem by a random amount. The name "simulated annealing" alludes to the metallurgic term meaning the heating and cooling of metal to achieve freedom from defects. The purpose of the random variance is to find close to globally optimal solutions rather than simply locally optimal ones, the idea being that the random element will be decreased as the algorithm settles down to a solution.

Classification by field of study

Every field of science has its own problems and needs efficient algorithms. Related problems in one field are often studied together. Some example classes are search algorithms, sorting algorithms, merge algorithms, numerical algorithms, graph algorithms, string algorithms, computational geometric algorithms, combinatorial algorithms, machine learning, cryptography, data compression algorithms and parsing techniques.

Some of these fields overlap with each other and advancing in algorithms for one field causes advancement in many fields and sometimes completely unrelated fields. For example, dynamic programming is originally invented for optimisation in resource consumption in industries, but it is used in solving broad range of problems in many fields.

Classification by complexity

This is actually problem classification in the strict sense. Some algorithms complete in linear time, and some complete in exponential amount of time, and some never complete. One problem may have multiple algorithms, and some problems may have no algorithms. Some problems have no known efficient algorithms. There are also mappings from some problems to other problems. So computer scientists found it is suitable to classify the problems rather than algorithms into equivalence classes based on the complexity.

Legal issues

Some countries allow algorithms to be patented when embodied in software or in hardware. Patents have long been a controversial issue (see, for example, the software patent debate). Some countries do not allow certain algorithms, such as cryptographic algorithms, to be exported from that country.

See also


* Algorism
* Algorithmic music
* Algorithmic trading
* Data structure
* Important algorithm-related publications
* List of algorithm general topics
* List of terms relating to algorithms and data structures
* Theory of computation
* Computability theory (computer science)
* Abstract machine

Notes

References

*Andraes Blass and Yuri Gurevich (2003), Algorithms: A Quest for Absolute Definitions, Bulletin of European Association for Theoretical Computer Science 81, 2003. Includes an excellent bibliography of 56 references.
*Yuri Gurevich, Sequential Abstract State Machines Capture Sequential Algorithms, ACM Transactions on Computational Logic, Vol 1, no 1 (July 2000), pages 77-111. Includes bibliography of 33 sources.
* Excellent reference source for mathematical "foundations".
* Cf in particular the first chapter titled: Algorithms, Turing Machines, and Programs. His succinct informal definition: "...any sequence of instructions that can be obeyed by a robot, is called an algorithm" (p. 4).
* In pages 1-9 Knuth gives the history and his definition of "algorithm". In particular he references Markov (1954).
*A. A. Markov (1954) Theory of algorithms. [Translated by Jacques J. Schorr-Kon and PST staff] Imprint Moscow, Academy of Sciences of the USSR, 1954 [i.e. Jerusalem, Israel Program for Scientific Translations, 1961; available from the Office of Technical Services, U.S. Dept. of Commerce, Washington] Description 444 p. 28 cm. Added t.p. in Russian Translation of Works of the Mathematical Institute, Academy of Sciences of the USSR, v. 42. Original title: Teoriya algerifmov. [QA248.M2943 Dartmouth College library. U.S. Dept. of Commerce, Office of Technical Services, number OTS 60-51085.]
* Reprinted in The Undecidable, p. 289ff. Post defines a simple algorithmic-like process of a man writing marks or erasing marks and going from box to box and eventually halting, as he follows a list of simple instructions. This is cited by Kleene as one source of his "Thesis I", the so-called Church-Turing thesis.
* Reprinted in The Undecidable, p. 223ff. Herein is Rosser's famous definition of "effective method": "...a method each step of which is precisely predetermined and which is certain to produce the answer in a finite number of steps... a machine which will then solve any problem of the set with no human intervention beyond inserting the question and (later) reading the answer" (p. 225-226, The Undecidable)
* Reprinted in The Undecidable, p. 89ff. The first expression of "Church's Thesis". See in particular page 100 (The Undecidable) where he defines the notion of "effective calculability" in terms of "an algorithm", and he uses the word "terminates", etc.
* Davis gives commentary before each article. Papers of Gödel, Church, Turing, Rosser, Kleene, and Post are included.
*

Secondary references

*, ISBN 0-671-49207-1. Cf Chapter "The Spirit of Truth" for a history leading to, and a discussion of, his proof. A wonderful biography.
*, ISBN 0-312010409-X (pbk.)
*, ISBN 0-8078-4108-0 pbk.
*, 3rd edition 1976[?], ISBN 0-674-32449-8 (pbk.)

External links

*
* Algorithms in Everyday Mathematics



Email this page
About Us | Advertise on This Site | User Agreement | Privacy Policy | Kids' Privacy Policy | Help
About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.
This is the "GNU Free Documentation License" reference article from the English Wikipedia. All text is available under the terms of the GNU Free Documentation License. See also our Disclaimer.