What is an algorithm and why are they useful?

Algorithms. They’re all around us. You might not have noticed but we are literally surrounded by them! Not only that, whether you realise or not you will have created and followed many algorithms just over the past few days!

Planned your route through the supermarket for the bits you need? Algorithm.

Made a (virtual) commute into work? Algorithm.

Cooked a meal following a recipe? Algorithm.

Built some new Ikea furniture? Algorithm.

So what exactly is an algorithm?

Algorithms are often used and cited in computing, but they are all around us.

Put simply, an algorithm is a list of rules to follow in order to solve a problem. Rules can mean steps and a problem can be something as simple as getting ready for work and school. It doesn’t have to be overly complex, although of course could be.

An algorithm could be anything from how to prepare your breakfast in the morning, which you likely do on auto-pilot through to manufacturing a vaccine for COVID-19.

Give me an example of an algorithm.

If we start at the more relatable and hopefully simpler end of the spectrum, let’s look at preparing breakfast in the morning. The algorithm for this could look like:

  1. Get a bowl.
  2. Get the cereal packet out of the cupboard.
  3. Pour a portion of cereal into the bowl.
  4. Get the milk out of the fridge.
  5. Pour a small amount of milk over the cereal in the bowl.
  6. Get a spoon from the cutlery drawer.
  7. Place the cereal packet back in the cupboard.
  8. Sit down and enjoy the cereal!
  9. Place the empty bowl and spoon into the dishwasher.

You likely do all of this on auto pilot because of so much practice!

Could we add more steps?

Of course. There’s many ‘right’ ways to do things. The important thing to consider is, if I follow the steps, will I solve the problem or complete the task. If it’s a yes, we’ve got a good algorithm.

Being specific.

Could do with a little more detail…

The success of an algorithm is usually down to it’s specificity. If you follow the steps above for your own breakfast routine, you’ll likely get it right through knowledge and experience. However, the real test is if you give it to someone else to try!

So, in the example above, have I been very specific? In some ways I have, but in others not so much. How much milk should I pour over my cereal? How much is a small amount? That’s probably going to be subjective depending on the person. It might even be subjective depending on the cereal. I like to drench Weetabix but I’ll accept less milk on my Cheerios!

Improvements

If I was improving the algorithm, I might make the following changes:

  1. Get a bowl.
  2. Get the cereal packet out of the cupboard next to the oven.
  3. Pour a 25g portion of cereal into the bowl.
  4. Get the milk out of the fridge.
  5. Pour 5ml of milk over the cereal in the bowl.
  6. Get a tablespoon from the cutlery drawer.
  7. Place the cereal packet back in the cupboard next to the oven.
  8. Sit down and enjoy the cereal!
  9. Once finished, place the empty bowl and spoon into the dishwasher.

Now this algorithm looks more detailed and therefore we’ve enhanced it so it’s more likely to be successfully followed by someone else.

So, when do I stop improving?

The short answer is, never. Through testing of algorithms and interpretation by others we often find unexpected circumstances that may affect completion of the problem or the efficiency in reaching the end goal. Maintaining an algorithm is a cyclical process.

Have any questions on algorithms? Maybe you have an example yourself? Drop them in the comments below!

You may also like...

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x