An algorithm is a well-defined procedure that takes input and produces output. The analogy to a recipe is good here, since a cook will take ingredients (the input), mix things together and cook it (the procedure), and produce a dish (the output).
The main difference here is that algorithms are mathematical or textual in nature. The algorithms we use in programming are any series of steps that produce an output we are interested in, for example, searching for an item in a list.
Once an algorithm is defined, we can name it and study its properties. The properties of an algorithm can be studied mathematically so that we know which ones will run faster given a larger amount of input.
An example would be sorting algorithms. A few common sorting algorithms are:
- insertion sort, like taking a deck of cards and inserting each card one by one into an already sorted order
- selection sort, like taking a deck of cards and going through the deck and finding the smallest card each time and putting it at the front of the deck
- merge sort, like taking a deck of cards and splitting it over and over again, sorting each partial deck, then merging them together in sorted order
- bubble sort, like taking a deck of cards, making multiple passes through it, and swapping adjacent pairs of cards that are out of order, until finally the smallest cards bubble to the top.