Sandwich Algorithm Lesson
Introduce the concept of algorithms using a sandwich recipe.
Inspiration
TEALS lesson: https://tealsk12.gitbook.io/intro-cs/unit_0/lesson_02
This video gives an idea of some potential misinterpretations: https://www.youtube.com/watch?v=BsUiEejG5sY
Introduction
Present the Algorithm Computers Introduction PowerPoint to give the students some background about computers and algorithms. In the middle of the presentation, there is a slide containing the outline for the sandwich activity.
Sandwich Activity
Give the students a chunk of time to come up with instructions to make a PB&J sandwich. Emphasize that the instructions they write should be precise, unambiguous, and complete. They should write the instructions on paper.
Algorithm Execution
After the students have finished, an instructor should read their instructions. The instructor should act as a computer and follow each step as literally as possible. If there is ambiguity, or if a step is not possible to complete, the instructor should point out the error. When an instruction is ambiguous or impossible, the instructor should interpret the algorithm in the most atypical (and hilarious) way possible. This will reinforce to students that many seemingly clear instructions can be taken many ways.
Common Errors
- Failing to open a container before using what is inside
- Response: Try (and fail) to access the inside in a humorous fashion (e.g. try to reach through the bag or jar, acting confused as to why you cannot reach the ingredient inside)
- Failing to specify in which orientation or position to use something (e.g. "grab the knife" but not by the handle, "put down the bread" but not on the plate)
- Response: use or place the ingredient in an obviously (and humorously) incorrect way (e.g. grab the knife (carefully) by the sharp end, put the slice of bread on the table next to plate, spread peanut butter around the crust instead of on the face)
- Using instructions that are too broad (e.g. "pick up the bread" to mean a single slice, "put the peanut butter on the bread" to mean spreading a small amount)
- Response: Ask for more detail, or interpret the instruction literally
- Combining multiple steps into one instruction (e.g. "spread peanut butter on the bread" without specifically opening the jar, putting peanut butter on the knife, using the knife to spread, etc.)
- Response: Ask for more detail
Most algorithms will fail. Instructors should read through many students' instructions for a while.
Debugging
Debugging is an important part of writing computer programs. Once enough students have had their instructions executed, give them a chance to rewrite their algorithms, fixing any of the failures from the original execution. There are more slides in the presentation to introduce debugging.
Suggested Schedule
Activity | Time |
---|---|
Introduction Presentation | 10m |
Students Writing Algorithms | 5-10m |
Executing Instructions | 10-15m |
Debugging Presentation | 5m |
Students Debugging Algorithms | 5-10m |
Wrap Up | 0-5m |