An algorithm is a method, or a set of step-by-step instructions for performing some task or calculation, especially for computer programs.
For example, suppose we want an algorithm to find the average of a list of numbers. We must add them up and then divide by n, where n is the count of how many numbers there are. The algorithm for this might look like:
start with a list of numbers (eg 2, 5, 99, -4, 20)
set the total to zero
start at the top of the list
repeat the following until end of list
get the next number from list
add it to the running total
At the end of the list
the average is the total divided
by the length of the list
When an algorithm is written out in this English-like way it is called 'pseudo-code'. It looks a little like computer code (programming), but is really meant to describe the algorithm to another person.
var list = [2, 5, 99, -4, 20];
var total = 0;
var average;
for(var i=0; i<list.length; i++);
{ total = total + list[i];
}
average = total/list.length;
So, as you can see, the algorithm is the method for getting the job done, which is then written in a computer language of your choice so it can performed by the computer.