No history yet

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:

  1. Wake up.
  2. Get out of bed.
  3. Get dressed.
  4. Brush your teeth.
  5. Eat breakfast.
  6. 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!

Lesson image

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.

StepInstruction
1Pick up your toothbrush.
2Put a small amount of toothpaste on it.
3Brush the top teeth.
4Brush the bottom teeth.
5Spit out the toothpaste.
6Rinse your mouth with water.
7Put 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?

Quiz Questions 1/5

What is an algorithm?

Quiz Questions 2/5

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.