Algorithm
- a well-defined sequence of steps
Informally, an algorithm (in short, Algo) is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, asoutput. An algorithm is thus a sequence of computational steps that transform the input into the output.
We can also view an algorithm as a tool for solving a well-specified computational problem.
For example, we might need to sort a sequence of numbers into non-decreasing
order.
Here is how we formally define the sorting problem:
Input: A sequence of n numbers (a₁, a₂,.........,aₙ).
Output: A permutation (reordering) (a'₁, a'₂, .... , a'ₙ) of the input sequence
such that a'₁ ≤ a'₂ ≤ ..... ≤ a'ₙ.
For example, given the input sequence (31, 41, 59, 26, 41, 58), a sorting algorithm
returns as output the sequence (26, 31, 41, 41, 58, 59). Such an input sequence is called an instance of the sorting problem.
An algorithm is said to be correct if, for every input instance, it halts with the
correct output. We say that a correct algorithm solves the given computational
problem. An incorrect algorithm might not halt at all on some input instances, or it might halt with an incorrect answer.
What kinds of problems are solved by algorithms?
Some Problems are:
- The Human Genome Project has made great progress toward the goals of identifying
all the 100,000 genes in human DNA, determining the sequences of the 3 billion chemical base pairs that make up human DNA, storing this information in databases, and developing tools for data analysis. Each of these steps requires sophisticated algorithms.
- The Internet enables people all around the world to quickly access and retrieve large amounts of information. With the aid of clever algorithms, sites on the Internet are able to manage and manipulate this large volume of data.
- Electronic commerce enables goods and services to be negotiated and exchanged electronically, and it depends on the privacy of personal information such as credit card numbers, passwords, and bank statements. The core technologies used in electronic commerce include public-key cryptography and digital signatures, which are based on numerical algorithms and number theory.
Algorithms are at the core of most technologies used in contemporary
computers.
Furthermore, with the ever-increasing capacities of computers, we use them to solve larger problems than ever before. As we saw in the above comparison between insertion sort and merge sort, it is at larger problem sizes that the differences in efficiency between algorithms become particularly prominent.
Having a solid base of algorithmic knowledge and technique is one characteristic that separates the truly skilled programmers from the novices. With modern computing technology, you can accomplish some tasks without knowing much about algorithms, but with a good background in algorithms, you can do much, much more.