Coding Adventures for Young Learners
Introduction to Algorithms
What's an Algorithm?
Have you ever followed a recipe to bake cookies? You have to follow the steps in the right order. First, mix the flour and sugar. Then, add the eggs. If you add the eggs before the flour, you'll end up with a gloopy mess, not yummy cookies!
An algorithm is just like a recipe. It's a list of step-by-step instructions for getting something done.
Algorithm
noun
A set of rules or steps to be followed to solve a problem or complete a task.
You use algorithms all the time without even thinking about it. Your morning routine is an algorithm. To get ready for school, you have to:
- Wake up.
- Get out of bed.
- Get dressed.
- Brush your teeth.
- Eat breakfast.
- Grab your backpack.
The order of these steps is very important. What would happen if you tried to eat breakfast before you woke up? It’s impossible!
Putting on your shoes and then your socks wouldn't work very well, would it? For an algorithm to work, the steps have to be in the correct order.
Algorithms Are Everywhere
Once you start looking, you'll see algorithms all around you. When you play a board game, the rules are an algorithm. When your parents use a map on their phone to drive somewhere, the phone is using an algorithm to find the best route.
Even something as simple as solving a math problem follows a set of steps. You've been using algorithms in school for years!
Think about how you solve a long multiplication problem. You multiply the numbers in a specific order, carry numbers over, and then add everything up at the end. That's an algorithm in action.
Let's Make Our Own
Creating an algorithm is like being a boss and giving very clear instructions to a robot. The robot can only do exactly what you tell it, so the steps need to be simple and in the right order. Let's write an algorithm for how to brush your teeth.
| Step | Instruction |
|---|---|
| 1 | Pick up your toothbrush. |
| 2 | Put a small amount of toothpaste on it. |
| 3 | Brush the top teeth. |
| 4 | Brush the bottom teeth. |
| 5 | Spit out the toothpaste. |
| 6 | Rinse your mouth with water. |
| 7 | Put your toothbrush away. |
See? Each step is small and clear. If you follow this algorithm, you'll end up with sparkling clean teeth every time. What other daily tasks could you write an algorithm for?
What is an algorithm?
Which of the following is the BEST example of an algorithm you might use every day?
Now you know that an algorithm is just a simple set of instructions to get things done.
