What is an algorithm?

Francesca Rosella explains how she uses algorithms when programming a piece of wearable technology

Algorithms are sets of step-by-step instructions for the computer to follow. They are at the heart of all computer programs.

You can think of an algorithm as similar to a food recipe. If you make a sandwich, you follow a set of steps to put the different ingredients together. You bring ingredients together, assemble them as you like, and produce a final product - the sandwich. If you were asked to write down instructions to make a sandwich, you could create a written algorithm.

Within your sandwich algorithm you would need to specify:

  • inputs - ingredients and quantities
  • the process - recipe or method
  • output - what the finished sandwich will be like
Input processing output diagram

Use of algorithms

Algorithms are used in all areas of computing. Examples include:

  • PageRank - Google's search engine uses a highly effective algorithm called PageRank to find the best matches for search terms. PageRank decides which pages are listed first when you search for something. This algorithm is highly sophisticated and played an important role in Google Search's success.
  • Weather forecasting - the Met Office uses weather forecasting algorithms to model weather patterns and make predictions.
Laptop running a program to track the predicted path of a hurricane

Algorithms are a great way of automating computer decisions. However, automating processes can lead to errors.

For example, the Amazon website uses algorithms to decide the price of products. In 2011, the price of a book called 'The Making of a Fly' (about the molecular biology of a fly) jumped to £14 million as the pricing algorithms used by Amazon to set and update prices started outbidding each other. This raised the book price.

Google's Diana Gorea explains how algorithms are used on the web and how they need to be efficient to maximise their speed