Overview

This is the 2nd day of a 3-lesson sequence in which the students will attempt to show the "art" of programming and introduce the connection between programming and algorithms. In the previous lesson the students established the need for a common language with which they can express algorithms to avoid ambiguity in how instructions would be interpreted. In this lesson the students will continue to establish the connection between programming and algorithms, with more emphasis on the "art" of algorithms. First, the students are presented with a new task for the "human machine" - to write a set of instructions to identify the smallest (lowest value) card in a row of cards on the table. Once again the students will try to establish a set of fundamental commands for doing this, and develop a more formal set of "low-level" commands for manipulating playing cards. Students are presented with a "Human Machine Language" that includes 5 commands and then must figure out how to use these primitive commands to "program" the same algorithm. At the conclusion several points about programming can be made, namely:

  1. Different algorithms can be developed to solve the same problem.
  2. Different programs can be written to implement the same algorithm.

Vocabulary

Goals

Students will be able to:

Purpose

The main point here is to connect the acts of writing "code" and designing algorithms, and to take some steps towards programming with code. To do this the students will imagine trying to write instructions for a "Human Machine" to complete a tightly defined task with playing cards. The teacher will introduce the term "algorithm" and what designing an algorithm means in computer science (i.e. programming). Then, the students will take a few steps to build up to writing an algorithm with "code." Here are the basic steps of the lesson and their underlying purpose:

Why the Human Machine Language? This language bears a strong resemblance to so-called "Low Level" Programming Languages - a sparse, primitive set of commands to directly control the physical/electronic operations of a computing machine. Other programming languages are built on top of the low level languages to provide more abstraction and functionality that combines low level operations into commonly used procedures. The most commonly known low level language is called Assembly Language. Please see the wrap up of the next lesson where we introduce students to low level languages.

Resources

Solution

There are several ways to solve the problems in the activity guides. Allow the students to discuss with their classmate or with the teacher about what is the most efficient way to set up this algorithm.

Teacher's Tip

We have prepared the same documents in different file formats for the lesson. The first file is in .docx format and has many graphic components. Another file is in .doc format and is a text only document. All the graphics in the first .docx file are described in narrative manner. There is also a .brf file, which can work with a refreshable braille display or a braille embosser. The PDF files are also included for convenience.

Getting Started

Yesterday's activity focused on the inherent difficulties of trying to express precise processes with written language. Remind the students that conclusions the class has arrived at include:

What is Algorithm Discussion

Some remarks for the discussion include:

Activity 1: Find Minimum Card Algorithm

Perhaps it goes without saying that in a Computer Science class the students are concerned with not just any processes, but computational processes - ones that can be executed by a computer - which have specific sets of constraints. The students often get started thinking about algorithms and computational processes by trying to rigorously act them out themselves as a sort of "Human Machine." When acting as a machine, the students can keep the limitations of a computer in mind. In this activity the students are going to pretend that they are a "Human Machine" that operates on playing cards on the table.

Download the "Minimum Card Algorithm - Activity Guide" and then follow the guide to allow the students to develop their own instructions to find the card with the smallest number value. If students prefer, allow them to do this activity independently. While working, consider the following questions for the students:

Tips

Discussion

As a class, look at the algorithms that students came up with. Most likely, these algorithms are not all the same. If a student is taking this class by himself or herself, help the student find out that there are many algorithms that would produce the same outcome. However, also point out to students that there are common tasks that they are making the "human machine" do. Ask them what are the commands or actions most of these instructions have in common. Ask them if they can define a language of common Human Machine commands for moving cards around.

Discussion Goal

Sample Set of Human Machine Commands:


Activity 2: The Human Machine Language

As a class, we have just identified a set of primitive commands that the students can use to operate on a set of cards. To be very concrete let's formalize this into a language as a class through the following activity.

Instructions for the Activity Guide

Discussion

The problem we identified with the last example speaks to the art and science of algorithm design and what can make it so interesting. The question is: can we fix the problem without adding more commands to the language? The answer is "Yes." If we can fix a problem without extending the language, that's a good thing. We can focus our attention on designing algorithms given these constraints.


Challenge Activity: Find Minimum with the Human Machine Language

First identify what's different about this problem setup for the Human Machine Language:

Now use the Human Machine Language to write the algorithm for finding the minimum card. NOTE: The students can just write the code, or the students can use the cutout strips of the commands and write values into the boxes.

Tips

Wrap Up

Yesterday the class discussed the need for a programming language. Today class came up with our own programming language and used it to implement an algorithm. The CSP definition of algorithm is: "a precise sequence of instructions for processes that can be executed by a computer and are implemented using programming languages." There are two facts about the algorithm and programming:

Remarks for the Students

These two facts - Different algorithms can be developed to solve the same problem and different code can be written to implement the same algorithm - embody the art of programming and what makes programming so fun, engaging and creative. In programming, just like art, we strive to make beautiful things.

  1. A beautiful algorithm is an elegant and clever idea for how to solve a problem.
  2. A beautiful program is an elegant use of whatever language structures are provided to make the algorithm actually work on a computer.

Standards Alignment