5-2 Introduction to Algorithms

  • Students will follow an algorithm to draw pictures constructed from 2D shapes. 
  • Students will use logical reasoning to debug and correct errors in the 2D shape algorithms.


Watch: Who is Grace Hopper?

YouTube Video

Grace Hopper was the first person to "debug" a computer. 
How did she do it?

Debugging and 2D Drawing

From Unit 1, you learned what an algorithm is. In this activity, you will use an algorithm to draw a house.
You will also learn how to "debug" (fix) an algorithm if it's not working properly.

The instructions written on the left is the algorithm.
  1. This algorithm is made up of a sequence of instructions to create a picture of a house. 
  2. On the right is how you would like the house to look.
  3.  There might be some mistakes in the algorithm, which means following it will not create the picture of the house you hoped for.
  4. Your task is to use logical reasoning to work through this algorithm to detect and correct any errors; we call this debugging.
2D Shape drawings_image 1_algorithm for drawing a house.png

With a partner: 
  1. One person will read each step of the algorithm on this worksheet and the other person will draw it on a blank sheet of paper.
  2. Check whether what you have drawn from the algorithm matches the picture.
  3. If it does then move on to next step; if it doesn’t fix edit the algorithm.
When editing the algorithm think about the use of logical reasoning to justify the changes you make:
  • Identify the difference.
  • Think about what you need to change.
  • Change the algorithm.

2D Drawing Worksheet

  • Using this worksheet, create a simple drawing made from 2D shapes in the right hand part of the table and write the algorithm for this drawing in the left hand box.
  • Purposefully include 3 mistakes in your algorithm. An example is shown below:

  • Once you have completed this, swap sheets with your partner.
  • Use logical reasoning to detect and correct the errors in your partner’s algorithm: you will debug it. 

Check Your Understanding

  • What is an algorithm? (Hint: You used algorithms to create the sequences of instructions for constructing the 2D shape drawings.)
  • What is debugging? (Hint: You used debugging to detect and correct the errors in the 2D shape drawings.)

If you finish early: Add text.