| • Science | • People | • Locations | • Timeline |
| Contents | ||
An algorithm is a finite set of well-defined instructions for accomplishing some task which, given an initial state, will result in a corresponding recognisable end-state (contrast with heuristic). Algorithms can be implemented by computer programs, although often in restricted forms; an error in the design of an algorithm for solving a problem can lead to failures in the implementing program.
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) until the task is completed. Correctly performing an algorithm will not solve a problem if the algorithm is flawed or not appropriate to the problem. For example, performing the potato salad algorithm will fail if there are no potatoes present, even if all the motions of preparing the salad are performed as if the potatoes were there.
Different algorithms may complete the same task with a different set of instructions in more or less 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.
In some countries, such as the USA, some algorithms can effectively be patented if a physical embodiment is possible (for example, a multiplication algorithm may be embodied in the arithmetic unit of a microprocessor).
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.
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 use. Stored data is regarded as part of the internal state of the entity performing the algorithm.
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 formalisation 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.
Algorithms are not only implemented as computer programs, but often also by other means, such as in a biological neural network (for example, the human brain implementing arithmeticArithmetic Arithmetic or arithmetics in common usage is a branch of (or the forerunner of) mathematics which records elementary properties of certain operations on numerals, though in usage by professional mathematicians, it often is treated as synonym fo or an insect relocating food), or in electric circuits or in a mechanical device.
The analysis and study of algorithmsTo analyze an algorithm is to determine the amount of resources (such as time and storage) necessary to execute it. Most algorithms are designed to work with inputs of arbitrary length. Usually the efficiency or complexity of an algorithm is stated as a f is one discipline of computer scienceIn its most general sense, computer science CS or compsci is the study of computation and information processing, both in hardware and in software. Introduction Computer science encomposses a variety of topics relating to computation, ranging from abstrac, and is often practiced abstractly (without the use of a specific programming languageAn alternate rewrite has been has been. Please refer to it for large rewrites. A programming language or computer language is a standardized communication technique for expressing instructions to a computer. It is a set of syntactic and semantic rules use 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. One way to embody (or sometimes codify) an algorithm is the writing of pseudocodePseudocode is a generic way of describing an algorithm without use of any specific programming language syntax. It is, as the name suggests, pseudo code — it cannot be executed on a real computer, but it models and resembles real programming code, and is.
Some writers restrict the definition of algorithm to procedures that eventually finish. Others include procedures that could run forever without stopping, arguing that some entity may be required to carry out such permanent tasks. In the latter case, 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.