What is an algorithm for kids?
Algorithm is a pretty big word.
Even if you aren’t quite sure what algorithm means, there is a chance you have heard people talk about computer algorithms.
But what exactly is an algorithm?
An algorithm is a set of step-by-step instructions that describe how to perform a task.
These steps are used to solve a problem or reach a result.
At Inspirit AI, we like to compare algorithms to making a recipe.
Algorithms are used in computer science and programming – not cooking – but algorithms work similar to recipes!
To make a peanut butter and jelly sandwich, you follow a specific process and set of steps:
Once you have created your PB&J, you can share your recipe with friends who now know how to recreate the process.
If you give your friend specific and clear directions, they can create a PB&J, just like yours!
If your directions aren’t very easy to follow, your friend might end up reaching a different result.
For example, let’s take a look at the following directions:
To a human who has made a PB&J before, these directions might make sense! But they aren’t nearly specific enough for a computer!
A computer might wonder:
An unclear, unspecific algorithm may put you in a sticky situation!
Even though the PB&J example is fun and easy to digest, algorithms are used in computer science – not cooking.
In computer science and programming, algorithms consist of lines of code that can solve problems (like math problems).
Computer algorithms have three main goals:
In our unplugged example of making a PB&J, our algorithm had the following goals:
In computer science, we use algorithms in several different ways:
Algorithms are all around us!
Google uses algorithms to rank search results, or decide the order websites appear when you search.
YouTube is another popular algorithm! You can search for videos (just like how you search on Google). Once you finish watching one video, YouTube will recommend other videos for you to watch.
Social media uses algorithms to recommend posts to users, based on their history.
What other examples of algorithms have you seen online? In our recent blog post all about artificial intelligence for kids, we share even more examples of algorithms in the world around us!
Algorithms are a set of step-by-step directions – and we can write them using code!
We can even use an algorithm to write… an algorithm!
Let’s take a deeper look at each of these steps to writing an algorithm.
1. Think about what you want your algorithm to do
Algorithms accomplish a task. That means they have an objective or a goal.
What do you want your algorithm to do?
Spend some time thinking and brainstorming before you start coding. This will help make the process easier!
2. Write out each step (in code!)
Once you have decided on an objective, you can start coding!
As you begin to write your code, make sure you write out each step. Be clear and specific with your code.
This step is important to make sure your algorithm actually works.
3. Test your code
Test out your code! Does your algorithm work?
You might notice that your code does not run correctly on the first try, and that’s okay.
In fact, that’s great!
Coding is all about solving problems and learning from your mistakes.
(In computer science, we call the mistakes in our code “bugs.”)
At Inspirit AI, we introduce elementary and early middle school students to computer science using Scratch, a block-based programming tool.
The best way to get more practice writing algorithms is to take a class!
Inspirit AI offers online coding classes for students of all ages, developed by Stanford and MIT graduates. Apply to our programs to learn more about algorithms for kids!
Learn more about our elementary school offerings here.
Learn more about our middle school offerings here.
Meet our team here.