Algorithms 2: Algorithms Unplugged
< Back to Building BlockHave you ever been in front of a TV or tablet screen, looking at the landing page of Netflix wondering what to watch? The proverbial question in your mind or being spoken out loud: What to watch?
As you sort through the library, you may ask yourself some of the following questions:
- Watch a reality TV show? No.
- Something fictional or factual? Factual.
- Do I want to learn something? Yes.
- Do I want to watch a documentary? Yes.
- Something by Ken Burns? No.
- Something by Neil deGrasse Tyson? No.
Subtitles, no subtitles? How much time do I have? Oh, I should really pick something, I’ve spent twenty minutes searching.
Why would you ask yourself these questions? Did the series of questions help narrow down choices by considering restrictions such as time or language and more subjective tastes such as only watching comedies?
Before moving onto the next step, consider what role asking questions plays in any problem-solving process?
In the prior step, questions helped narrow down choices for the very open-ended problem of what to watch. How could adding a small amount of structure to prior questions save time next time you can’t figure out what to watch? How could writing down a list of questions in a specific order help answer the central question?
To explore the idea of asking a question then breaking it down into specific steps, let’s consider a high school science class.
Can you recall the physical science formula to convert Fahrenheit to Celsius? C = 5/9 (F - 32)? The formula states that in order to find a Celsius value, you first need to figure out that temperature in Fahrenheit and remember algebra’s order of operation rules.
To break down the task, you could create a list of steps similar to following a recipe.
Step 1: Start
Step 2: Read temperature in Fahrenheit
Step 3: Subtract 32 from Fahrenheit temperature
Step 4: Multiply by 5
Step 5: Divide by 9
Step 6: Show temperature in Celsius
Step 7: End
Above, you took a formula and turned it into a list of steps for solving a particular problem (converting Fahrenheit to Celsius). Another name for this process of drafting a step-by-step set of instructions is an algorithm. An algorithm must have a set of unambiguous (order, explicit) rules and a clear stopping point. There may be more than one way to solve a problem; so, there may be more than one algorithm for a given problem.
Could the steps above be shortened?
Imagine you met a visitor from another dimension almost identical to ours except for one tiny detail -- their traffic lights use different colors to control traffic flow.
On a scrap sheet of paper, create a list of steps to teach them how to read a traffic light in our dimension.
After writing your algorithm read over each step and consider the following criteria for a good algorithm (Douglas H. Fisher, 2019):
- Correctness: the algorithm performs the task without error
- Efficiency: the algorithm uses as little time and/or as little space as necessary, but there is almost always a tradeoff between time and space
- Comprehensibility: the algorithm can be understood (which helps with human efficiency)
So you write your algorithm and show it to the interdimensional visitor, but they look perplexed.
“What is this?” they ask.
“Rules for reading traffic lights, like a recipe with steps,” you say.
“No, a recipe looks like this.” They pull out their phone (strangely with service) and search for something then show you the graphic below. They explain this is a recipe to cook cup noodles.
You look at other “recipes” on this website and realize another difference between your interdimensional worlds: their cookbooks are filled with flowcharts not written out as step-by-step lists.
A flowchart is a diagram that visually presents the sequence of steps (flow) through a process (procedure) by using connecting lines and a set of symbols. Since an algorithm is a sequence of steps, a flowchart can be used to draw an algorithm.
Consider the algorithm you created for traffic lights and convert the steps to a flowchart. Use the key on this step to become familiar with the symbol convention used when drafting flowcharts.
Below are a few simplified guidelines for drafting a flowchart and ANSI symbols adapted from International Organization for Standardization (ISO), ISO 5807 (https://www.iso.org/standard/11955.html).
- Start: Begin a flowchart with a terminal symbol (oval) with the word Start.
- Arrows: Connect all symbols with flowlines (arrows).
- In & Out: Symbols can have one entry point on the top of the symbol and an exit point at the bottom.
- Exception: Decision symbols (diamonds) have two exit points, right and left sides OR one side and bottom.
- Readability: Try to keep flowcharts “flowing” from top to bottom and left to right.
- Breaks: Connector symbols connect breaks in a flowchart when going from one page to another or from the bottom of the page to the top.
- End: End a flowchart with a terminal symbol (oval) with the word End or a contentious loop.
Reference the examples below to draft the flowchart depicting the traffic light algorithm.
You look up, proudly holding up your traffic light flowchart towards the interdimensional visitor, but they are gone. You shrug and walk back to your car.
Before you start your car engine, off in the distance you spot a traffic light with five lights, the third bulb radiating light blue. Panic setting in, you turn to the passenger seat and find a flowchart titled Traffic Lights in Planet Htrae...
Coming back to our dimension and wrapping up this activity, consider the following questions:
Reflection
☞ What advantages do flowcharts have over a numbered list of steps?
☞ Provide an example of a task or real-world problem in which creating a flowchart algorithm could be beneficial?
☞ Consider a concept, project, or activity that your students tend to struggle with, how could requiring students to create a flowchart be beneficial to the learning objectives of that lesson?
Want to learn more about Algorithms?
Read more about algorithms in everyday life in this presentation by Douglas H. Fisher from Vanderbilt University
Watch the video below on Computational Thinking and Algorithm Design by Curriki
Learn more about flowcharts in these blog posts on the basics of flowcharts or complete guide of flowcharts.