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
- S1.B Design algorithms for a program.
- 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
Warm-up / Motivate
To introduce algorithms, have students 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.
You could have students use AI to help revise their algorithms. If you choose to include AI, ensure that you are including steps for students to critically analyze the results of using AI. Students should be careful to resist blindly following the results provided.
Learn
As a group or on their own, have students review the tutorial: Learn - Introduction to Algorithms.
Warm-up / Motivate
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: You can circle back to this activity to help students to continue to understand classes and objects by having them identify the objects in the game.
Learn
Students can learn about how to represent decisions and loops in their algorithms by working through the tutorial: Learn - Algorithms with Decisions and Repeation.
Additional Examples
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.
Practice
Have students complete the practice activities: Practice - Introduction to Algorithms Practice
Wrap-up / Extend
As students are asked to write programs, it is a good practice for them to write out an algorithm prior to writing their code.
It is recommended that students share their plans with you in advance of writing their program. This allows you to provide feedback and guide thinking, especially when algorithms get more complicated. Once they have taken time to think through what they are planning to program, the amount of time writing the program will take is typically a lot less.
Often students will resist planning a program before writing it. It is more satisfying for them to just start writing program code. However, starting without thinking about the program they are writing or the problem they are trying to solve, often leads to more frustration later on. It is recommended to allow students choice and flexibility in the way they want to write their plan (pseudocode, bullet points, flowchart, other).
Next Lesson
Lesson Plan: Determining the Data Type