Algorithms (optional lesson)

This is an optional lesson for additional learning

  • Learn what an algorithm is
  • Practice making an algorithm

These are the activities for this lesson:

WHAT IS AN ALGORITHM?

Most kids who grow up in North America love peanut butter and jelly sandwiches. Watch Johnna and Evan give their father, Josh, instructions to make a sandwich.

Source: “Learning about Artificial Intelligence: A hub of MIT resources for K-12 students”, MIT Media Lab

In the video, Josh, the dad, won’t do anything unless he is told to in simple step-by-step commands. Just like a computer, he only understands exact and precise instructions.

Johnna and Evan gave their father an algorithm to make a sandwich, with mixed results.

An algorithm is a set of step-by-step instructions. In order to make a computer do something, you need to give it an algorithm.

In Technovation Girls, you will learn how to write algorithms to make a mobile app!

Let’s practice writing explicit instructions for someone to follow.

Best practices: Encourage students to break down the task into small steps. Keep them excited by reminding them that this is the first step to coding. 

Optional activity: Do the Peanut Butter and Jam activity with your students!

More background: European schools experimented with ways to teach computer science to young young kids (4-5 years old) but it’s a really fun activity to do with anyone!

They wanted to illustrate that computers are not smart. They are just very fast (and dumb) machines that do whatever we program to tell them to do. They did this by acting like computers and the kids “programmed” the computers/teacher to make a PB&J. This is quite hilarious if done correctly because the goal is to take the commands as literally as possible. If the students first step is “Spread the peanut butter on the bread” then teachers/computers will not do the obvious things first they will do the literal thing which would probably be to spread peanut butter all over the ENTIRE loaf of bread (since the student didn’t specify just one piece of toast).

There is an example video here with more instructions and information. 

Guiding Questions to ask students: Are there any other games that need an algorithm to play them? Think about any of those Diner games where you have to make people’s orders. First you cook the meat, chop the veggies and then put it all together on a plate! Like Overcooked! Are there any other real life games that use an algorithm? What about a rubik’s cube? You repeat certain patterns until the squares are moved where you want them, that’s an algorithm!

Mentor tips are provided by support from AmeriCorps.

stylized A, AmeriCorps logo in navy

ACTIVITY1: WRITE AN ALGORITHM

There are two options here for an algorithm activity. You can do one or the other, or both. The first activity is a physical one (dancing!) so a good option if your team is meeting in person. If you are meeting virtually, you might want to try the second option, a drawing activity. Click on either activity to read instructions.

REFLECTION

Now you have a sense of what it takes to create an algorithm. You’ll create your own algorithms to tell your mobile app what to do.

recipe book
Would you approach giving instructions to someone else differently now?
If you could rewrite your algorithm from the activity, what parts would you change?
Previous slide
Next slide

REVIEW OF KEY TERMS

  • Algorithm – step by step instructions that explain how to do something

ADDITIONAL RESOURCES

If you want a little more information about what an algorithm is, this is a good video to watch.