Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Lesson plan

Topic 4 Algorithmic Thinking 2


Objectives:
 Know the difference between lossy and lossless compression
 Create algorithms for compressing data
 Know how knowledge of letter frequency can help with compressing text

Content

Starter
PowerPoint Guide: Lesson 4 Algorithmic Thinking 2

The starter asks students to consider a famous phrase. Ask them how they would reduce the
number of characters (including spaces) to a smaller number. Some ideas for compressing
could include missing out characters, using digits or using emoji.

Main
Compression
Take students through the two types of compression, lossy and lossless. This lesson firstly
looks at lossy compression which is rarely used for text. However, this is an easy way for
students to see how compression can be undertaken. Ask them to create an algorithm to do
their compression. This most likely will start with IF statements. Once they have completed
their algorithm, take them through the Answers slide.
Hand out Worksheet 4 and ask students to complete Task 1.
Lesson 4 Worksheet 4

Lesson 4 Homework 4 Answers

Locked-in syndrome
Explain to students that this is a real condition. Jean-Dominique Bauby suffered from this
syndrome and wrote an entire book ‘The Diving-Bell and the Butterfly’ via blinking.
Ask students to work in pairs. Each partner then thinks of a word and tries to communicate it
with their partner by simply blinking. They will find that this process is quite time consuming
with each letter taking several seconds to establish.

Letter order
We now use algorithmic thinking to see if we can make this process more efficient. In the
English language, certain letters are far more common than others. So, we can reorder the
list so that fewer letters need to be considered. Ask students to consider how the chart should
be re-ordered with the knowledge about letter frequency. The complete chart is shown on the
Answers slide.
Ask students to complete Task 2 on Worksheet 4.

Another algorithm
Explain to students that Computer Scientists are constantly looking to improve their solutions
and algorithms to the problem. A more elegant solution may execute faster, use less memory

Key Stage 3 Computational thinking and logic © 2020 PG Online Ltd 1


or fewer instructions or be easier to understand.

The alternative algorithm presented here is to use a binary tree. More astute students may
notice that a line break is used – they would need to either blink with both eyes or pause to
achieve this. Using line breaks simplifies the binary tree we have created. In Computer
Science, this method of compression would use Huffman coding (see here:
https://en.wikipedia.org/wiki/Huffman_coding).
Ask students for the word represented. The answer is TEN.

What does this say?


Now ask for the longer question. This time the binary tree has changed slightly to include a
space character. The _ symbol has been used to avoid confusion with the top node of the
tree. The answer is given on the following slide.
Ask students to complete Task 3 on Worksheet 4.

Storing text with ASCII


In (extended) ASCII, each character will need 8 bits to store it. Ask students to calculate the
number of bits needed to store “HAPPY BIRTHDAY” (excluding the speech marks), then to
calculate the number of bits required to store the compressed version with the binary tree.
Students should be able to see the significant saving in the number of bits used.

Why use compression?


Now show students a use of compression that they are likely to use on a regular basis. The
raw data for HD video needs around 3 gigabits of data per second. By transmitting
compressed data, it is possible in just 25 megabits per second. Students may be interested
that this is the minimum rate that Netflix requires for use of the HD service.
Ask students to complete Task 4 on Worksheet 4.

Plenary
Ask the first question on the slide to the class, then ask students to work in pairs to find the
word represented by the binary and binary tree. Remind students of the different solutions
that were given to solving the problem of Locked-in syndrome. All the algorithms were correct
and solved the same problem – however, it should be clear to students how some algorithms
are far better than others in the way they solve the problem.
Hand out Homework 4.
Lesson 4 Homework 4

Lesson 4 Homework 4 Answers

Key Stage 3 Computational thinking and logic © 2020 PG Online Ltd 2

You might also like