An algorithm (pronounced al-go-ri-them) is a step by step guide on how to do something.
We use them all the time, although you probably didn't realise. Ever followed a recipe? That is an algorithm.
Do you know how to use the column addition method? Then you have learned and applied an algorithm.
It is important that the steps are clear. This is why if you follow a recipe they often split it up into parts, so it is easy to see what to do and in which order.
Algorithms are used in computing too. It is even more important to be clear when writing instructions for a computer as they cannot guess what you mean. When we give instructions to computers we need to write code or use a flow chart. There are lots of different types of code (they are called languages) but they work in the same ways.
Look at the following algorithm. Try to work out what it is for.
boil kettle
put teabag into tea cup
add milk
put water into kettle
take out teabag
stir with a spoon
add one teaspoon of sugar
Could you guess this was supposed to be the instructions for how to make a cup of tea? What was wrong with the algorithm? What do you need to do to improve it?
Now try writing a short algorithm for yourself. Imagine you are giving your algorithm instructions to a robot. Would the robot know what to do?
You could try writing an algorithm to explain how to:
walk from your school to the nearest park
make a snow angel
pat a dog
grow a sunflower
Choose all the tasks below that can be completed by following an algorithm.
Follow this algorithm and work out the output at each step.
Output | |
---|---|
\text{Step 1: Start with $80$} | |
\text{Step 2: Add $19$ to $80$} | |
\text{Step 3: Round the result to the nearest ten.} |
For an algorithm you need to make sure each step is clear.
You also have to make sure you give the correct order