Algorithms

An algorithm is a set of rules followed to solve a problem or complete a task.

Algorithms exist outside the world of computing – if you follow a recipe to mix a great martini (and I’m sorry Bond, but that means stirred with gin, not shaken with vodka), then you are using an algorithm.

We can break the process down into inputs, algorithms, and outputs.

Using the Martini example above, the inputs would be the ingredients we use to make the drink. The algorithm is the rules we follow to mix the drink – “Measure and pour ingredients into a mixing glass. Stir the ingredients”, etc. Since we know which ingredients we are using and are following an algorithm (the recipe) to make the drink, we should be able to predict the output – in this case, a gin Martini.

Back to technology and computing.

A common computing task is sorting a list of data into ascending or descending order, for example, taking exam results and sorting them from the highest to lowest grade.

There are many algorithms that can be used to sort large lists efficiently, and each is a variation of taking a list of data as the input, applying a sort algorithm, and then outputting the sorted data as the result.

It’s important to remember that computers are incredibly powerful, but they are not intelligent in the same way as humans. While they are great at following well-laid instructions or algorithms, that’s exactly what they will do – they’ll follow the instructions as they have been programmed.

Many things you would take for granted when speaking with someone must be explicitly instructed on a computer.

Let’s use the example of the Martini again.

The first instruction in our recipe is “Measure and pour ingredients into a mixing glass”. What does measure mean? You’d probably guess (correctly) that I mean the amount of liquid we need for the recipe, but a computer won’t automatically know that – we could ask it to find the length of the bottle or the distance between the bottle and the mixing glass.

This is why it’s so important for programmers to think logically and break everything down into small steps when writing code. If they don’t, they are liable to run into bugs and issues when the software executes exactly as it was written rather than how it was intended.

Machine learning algorithms

Machine learning algorithms are a special type of algorithm that uses data to make predictions or decisions.

There are many different types of machine learning algorithms. A supervised learning algorithm will use a training data set with known inputs and outputs to create a machine learning model (algorithm). This model can then be applied to future data where the inputs are known, and we are trying to predict the outputs.

alt_text

We can use the example of predicting house prices to explain this process.

We start with our training data which includes inputs like the size of the houses, location, and the number of bedrooms and bathrooms. Since this is training data, we also know the outputs, and the price each house most recently sold for.

We can use our training data to build a machine learning model, and once this is ready, we can apply it to new (non-training) input data to predict the price of a house.

Next:
Databases