An algorithm in principle is a series of step by step instructions in order to solve a problem. Algorithms have an input which goes through a series of computations and finally produces an output.
A recipe is a good example of an algorithm because it tells you what you need to do step by step. It takes inputs (ingredients) and produces an output (the completed dish).
The words ‘algorithm’ and ‘algorism’ come from the name of a Persian mathematician called Al-Khwārizmī.
Informally, an algorithm can be called a “list of steps”. Algorithms can be written in ordinary language. In computing, an algorithm is a precise list of operations that could be done by a Turing machine. For the purpose of computing, algorithms are written in pseudocode, flow charts, or programming languages.
There is usually more than one way to solve a problem. There may be many different recipes to make a certain dish which looks different but ends up tasting the same when all is said and done. The same is true for algorithms. However, some of these ways will be better than others.
If a recipe needs lots of complicated ingredients that you do not have, it is not as a good as a simple recipe. When we look at algorithms as a way of solving problems, often we want to know how long it would take a computer to solve the problem using a particular algorithm.
When we write algorithms, we like our algorithm to take the least amount of time so that we can solve our problem as quickly as possible.
In cooking, some recipes are more difficult to do than others, because they take more time to finish or have more things to keep track of. It is the same for algorithms, and algorithms are better when they are easier for the computer to do. The thing that measures the difficulty of an algorithm is called complexity. When we ask how complex an algorithm is, often we want to know how long it will take a computer to solve the problem we want it to solve.