Skip Top Navigation Bar

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

Skills

Student Outcomes

Students will be able to:

Duration: 2 - 3 class periods

Resources

Background

We live our lives through algorithms with patterns and routines. These routines are:

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.

  1. Open up the text messaging app on my phone
  2. 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
  3. Type the message to the person
  4. 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:

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!

  1. Put students into groups of 3 to 4.
  2. 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.
  3. 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.