Posted by admin at April 16, 2020
Computers are particularly useful because they perform repeatable tasks in a predictable way (even when you’re frustrated with your computer for not doing what you want). When you open a word processor or play a computer game, the computer operates against a set of commands or instructions that a team of programmers wrote and those instructions tell the computer what to do and when it needs to do them. These instructions always do the same thing and, when the program is written well, it does them consistently and without errors.
These instructions are called “algorithms”. Author Yuval Noah Harari defines an algorithm this way: “An algorithm is a methodical set of steps that can be used to make calculations, resolve problems and reach decisions. An algorithm isn’t a particular calculation, but the method followed when making the calculation.” Some have referred to an algorithm as a recipe. But put simply, an algorithm is a repeatable set of steps that can take inputs and that produce a predictable, consistent output.
There are many popular metaphors that educators have used to illustrate algorithms and one of my favorites is the steps used when making a peanut butter and jelly sandwich. We can describes the steps–the algorithm–for making this sandwich this way:
Step 1: set out the ingredients: peanut butter, jelly, bread, and a spreader
Step 2: open the jars of peanut butter and jelly
Step 3: Set out two pieces of bread on a flat surface
Step 4: Spread a thin amount of peanut butter on one slice of bread
Step 5: Spread a thin amount of jelly on the other slice of bread
Step 6: Place one slice of bread on top of the other
Step 7: Enjoy!
Notice that this is a very rudimentary description. We can get much more specific on each of the steps. For example, we could specify exactly how much peanut butter and jelly to spread in steps 4 and 5. In step 6, we didn’t specify that the bread should be placed on top of each other with the peanut butter and jelly sides of the bread facing each other (not doing this would result in a very messy sandwich). But the point is, we’ve described a process for making the sandwich and the process is repeatable and always results in the same output: a sandwich.
Of course, because this is a very imprecise set of instructions, each sandwich will turn out a little bit different. Still, at a very high level, we end up with essentially the same results. Computers follow similar instructions but computer systems are very precise and the instructions they follow generally result in output that is much more consistent.
We’re now getting closer to understanding the relationship between computer science and logic. Logic follows this algorithmic model by describing a consistent way in which ideas should relate to one another. It provides a set of recipes we can use to organize thought.