Introduction to Algorithms Lesson Plan
Overview
This lesson is meant to be used during the first week or so of a new course on Java. It is for students who have no background in computer science or in writing algorithms and programs.
Learning Objectives
- 1.1.A.1 Represent patterns and routines using everyday language.
- 1.1.A.2 Recognize when the algorithmic components of sequencing, selection, and iteration are being used in patterns and routines.
Skills
- S4.A Explain best practices for using generative artificial intelligence when creating programs.
Student Outcomes
Students will be able to:
- recognize algorithms in their real-life
- recognize selection through decisions that need to be made and iteration through repeative processes
- represent algorithms using either flowcharts or pseudocode
Duration: 2 - 3 class periods
Resources
Background
We live our lives through algorithms with patterns and routines. These routines are:
- how we start our day by getting up and getting ourselves ready
- the route we take to school and work
- the recipe we follow when we are cooking dinner in the evening
- the way we go about our budget and paying our bills
All of these routines have steps we take often without thinking too much about them. Some of these steps require us to make decisions, such as our route to work based on traffic, what we wear based on the weather. Some of these steps are repeative, such as when we have multiple bills to pay, or we are plating up the same dinner once for each member of our family.
Computers need step-by-step instructions to operate. These instructions come through programs that represent the algorithms that the computer needs to follow. Similar to the routines and patterns in real-life, there is an order of steps with decisions and repeated patterns. Unlike when we insert a step into our routine without thinking about it, because we do it every day, the computer needs each individual step specified in order to function properly and provide the correct result.
Algorithms can be written in multiple ways, such as flowcharts and pseudocode. Flowcharting can be considered outdated and too rigid, but for some students, it provides a more structured way to look at the algorithm that would assist them later when translating an algorithm into program code. Using pseudocode allows students to write the algorithm using their own words and often in steps.
For example, the following represents an example of pseudocode that could be used to send a text message to a friend.
- Open up the text messaging app on my phone
- Is there a prior to text to this person at the top of the list of text messages?
- If yes, click on the series of messages
- If no, click on the icon to start a new message
- Is the person in my contacts list?
- If yes, type the person's name in the search section
- Select the person's name from the contacts
- If no, type in the person's phone number
- Type the message to the person
- Send the message
We can use flowchart symbols to create this same algorithm. In the flowchart, the following symbols are used:
Symbol |
Description |
|
Used to start and end the algorithm. |
|
Used to represent a single step. |
|
Used to make a decision, with the steps to take when it is true, going to the right and the steps to take when it is false, going to the left. Also can be used for representing the decision for whether or not the statements should repeat. |
|
Used to create a path for the algorithm to follow from one step to the next step. |
The following is the flowchart representation of the algorithm written in pseudocode above.
Activities
Activity 1: Teach a Fellow Student Something
After providing students with background on what algorithms are, have them write the steps of something that they know. They need to write the steps thorough enough for another student to follow. Here are some ideas:
- write the steps required to make a paper plane. Have another student follow those steps. Attempt to fly these planes down the hallway. Was your paper plane successful? If not, what alterations need to be made to the algorithm to make it more successful? Did you forget a step that you would've done automatically?
- write the steps required to do something you are good at. Have another student follow those steps. Where they successful? If not, what alterations need to be made to the algorithm to make them more successful? Did you forget a step that you would've done automatically? Some ideas for what you want to teach are as follows:
- tie shoes,
- put on make-up,
- solve a math problem,
- play a few notes of an instrument.
Follow up by identifying where in the algorithm you have written in decisions and loops.
Activity 2: Algorithms in Games
Supplies: Children's games, such as Candy Land, Trouble, Chutes & Ladders, Sorry!
- Put students into groups of 3 to 4.
- Have students spend 10 - 15 mintues playing the game. Ask them to pay close attention to the steps in playing the game and the decisions and repeative steps as they play.
- Using large post-it paper, have students write out the steps of the algorithm to playing the game. You can introduce students to the symbols used for flowcharts or they can write the algorithm using pseudocode instead.
Follow up: Identify the objects in the game. You can circle back to this activity to help students to continue to understand classes and objects.