Algorithms

WHAT IS AN ALGORITHM?

An algorithm

  • Is a set of steps to complete a task.
    • The order of the steps is important!
  • Should be easy to understand by the user.
list of 3 steps

In this video, watch as this dad teaches his kids a lesson about why algorithms must be exacteasy to understand, and in the right order.

WHAT DO YOU THINK?

peanut butter and jelly sandwich
  • What was the algorithm the kids were writing?
  • Why did their first attempts fail?
  • How did they improve their algorithms?

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

ALGORITHMS MUST BE EXACT!

Computers cannot make decisions on their own!
 
Just because you understand what you are saying, does not mean the computer does!

ALGORITHMS IN CODING AND AI

Computers don’t understand human languages.
 
Special programming languages translate human steps so the computer can understand.

ACTIVITY: DRAWING SHAPES WITH ALGORITHMS

Follow the directions in the worksheet

Stop and Discuss

How did the activity go?

  • Did your partner draw the shape correctly?
  • What worked?
  • What didn’t work?
two girls talking

If your partner didn’t get it right, try fixing your algorithm so they can follow the steps!

TIPS TO REMEMBER

  • Be exact!
  • Put things in the right order, called a sequence
  • The computer can only do what you tell it to do!