The shape of the lesson
By the end of the lesson, learners can
- Why compress?: Smaller files help everyone who stores or sends them.
- Lossless: run length encoding: In the lab, type some text or paint a 1-bit image and watch RLE replace each run of identical values with a count and the value.
- Lossy: data is gone: Switch the lab to lossy mode and reduce the resolution, colour depth or sample rate.
- Why: less storage, less bandwidth, shorter transmission time.
- Lossy: data permanently removed (resolution, colour depth, sample rate, sample resolution).
- Lossless: no permanent loss; the original is rebuilt exactly (RLE).
- RLE: each run of identical values becomes a count and the value.
One picture every idea returns to
Compression reduces the size of a file, so it needs less storage space, less bandwidth and a shorter transmission time. Lossy compression permanently removes data, for example by reducing the resolution or colour depth of an image, or the sample rate or resolution of a sound; the original cannot be recovered. Lossless compression reduces the size without permanent loss of data, so the original file can be rebuilt exactly; run length encoding (RLE) is an example.
Forty-five minutes, phase by phase
| Time | Phase | What happens in the room | Grouping |
|---|---|---|---|
| 0 to 5 min | Hook: predict | Open with the question in the title, Smaller files.. Photos, songs and videos are big, and big files are slow to send and fill up storage. Put the figure on the board: it is the one picture every idea in the lesson returns to. | Whole class, then pairs |
| 5 to 13 min | Teach and check: Why compress? | Smaller files help everyone who stores or sends them. | Whole class, then pairs |
| 13 to 21 min | Teach and check: Lossless: run length encoding | In the lab, type some text or paint a 1-bit image and watch RLE replace each run of identical values with a count and the value. Project tab 5 of the lab (Run length encoding) and let a student drive it while the class predicts. Model the worked example Encode and count on the board, one line at a time. Your turn: Decode the RLE data 3R 2G 5B. | Pairs |
| 21 to 30 min | Teach and check: Lossy: data is gone | Switch the lab to lossy mode and reduce the resolution, colour depth or sample rate. Project tab 5 of the lab (Lossy compression) and let a student drive it while the class predicts. | Anticipation / Reaction Guide |
| 30 to 36 min | Check | The four Stage 1 questions from the student lesson, answered on mini whiteboards or by show of fingers. Re-teach the one most get wrong. | Individual, then whole class |
| 36 to 43 min | Plenary | The exam-style questions from Stage 2, one at a time: thirty seconds alone, then a random call. The feedback lines in the key give the examiner's wording. | Individual, random call |
| 43 to 45 min | Exit and homework | Set the worksheet below (6 questions, 13 marks). Learners self-assess against the objectives before they leave. | Individual |
Protect the parts that carry the learning
The sequence carries about fifty minutes of material, so the lab is driven by one student while the class predicts rather than explored freely. Times are a guide.
Protected: the check at 30 minutes. It is the only individual read on whether the key idea landed, and it is not cut.
Cut first if the build overruns: the last check in Lossy: data is gone, never the check or the plenary.
In a 60 minute block: run worksheet questions 1 to 3 in class as a Rally Coach set and model both the hardest worked example and its check live.
Anticipation / Reaction Guide
Before the lesson, students mark five statements true or false. After the teaching they mark them again and justify any change of mind in one sentence each. The statements come from the examiner traps below.
The full structure, with its variations and the other twelve, is on the cooperative-learning page.
What to head off, and how
| Trap learners fall into | Teaching move that pre-empts it |
|---|---|
| "It makes the file smaller" only restates compression. | For a mark, give the effect: less storage, less bandwidth or a shorter transmission time. |
| RLE does not always make a file smaller. | ABCD encodes as 1A 1B 1C 1D, which is twice as long. |
| Never choose lossy compression for text or program files: a lost character or instruction changes the meaning or stops the program working. | Return to Lossy: data is gone: ask a pair to state the correct version and show it on the lab before moving on. |
Lossy and lossless compression: worksheet
6 questions, 13 marks. Written in the style of the papers; no past paper question is reproduced.
Give two reasons why files are compressed before they are sent over the internet.
Describe the difference between lossy and lossless compression.
Use run length encoding to compress the text PPPPPQQRRRRRRR.
The text PPPPPQQRRRRRRR is stored using 1 byte per character. In the RLE version each count and each character uses 1 byte. Calculate the number of bytes saved.
A school uploads photos to its website and also sends spreadsheets of exam marks. State which type of compression should be used for each and justify your answers.
A student says "run length encoding always makes a file smaller." Explain, with an example, why this is not true.
Answer key and marking notes
- Less bandwidth is needed.
- The transmission time is shorter (also accept: less storage space is needed).
- Lossy compression permanently removes data, so the original file cannot be recovered.
- Lossless compression reduces the file size without permanent loss of data, so the original can be rebuilt exactly.
- Runs: 5 P, 2 Q, 7 R.
- 5P 2Q 7R.
- Original 14 bytes; RLE 3 pairs = 6 bytes.
- 14 − 6 = 8 bytes saved.
- Photos: lossy, because the file is much smaller so the page loads faster.
- The data lost from a photo is unlikely to be noticed.
- Spreadsheets: lossless, because every value must be kept exactly; losing data would change the marks.
- RLE only saves space when there are runs of repeated values.
- e.g. ABCD becomes 1A 1B 1C 1D, which is 8 values instead of 4, so the file is larger.
6 multiple-choice questions on this lesson
From the topic question bank. Assign them in the app for a marked score in your gradebook, or run the topic as a class game.
Which is a benefit of compressing a file before it is sent over the internet?
- AIt uses less bandwidth, so it is transmitted in a shorter time
- BIt always improves the quality of the file
- CIt stops the file from being intercepted
- DIt removes any viruses in the file
Which statement describes lossy compression?
- AData is permanently removed, so the original file cannot be recovered
- BThe file is made smaller and can be rebuilt exactly as it was
- CRepeated values are stored as a count and the value
- DThe file is split into packets before it is sent
A school compresses four files before emailing them. Which file must be compressed using lossless compression?
- AA spreadsheet of students' exam marks
- BA photo of the school sports day
- CA recording of the school choir
- DA video of the school play
The row of pixels shown is compressed using run length encoding (RLE). What is the encoded data?
- A3W 5B 2W
- B5W 5B
- C3B 5W 2B
- D3W 5B
The text WWWWWWWWWWBBWWWWWW is stored with 1 byte per character. It is compressed using RLE, where each count and each character uses 1 byte. How many bytes are saved?
- A12
- B6
- C15
- D3
The text ABABABAB (1 byte per character) is compressed using RLE with 1 byte per count and 1 byte per character. What happens?
- AThe file grows from 8 bytes to 16 bytes, because every run has a length of 1
- BThe file shrinks to 4 bytes, because the pattern AB repeats 4 times
- CThe file stays at 8 bytes, because RLE never changes text
- DThe file shrinks to 2 bytes, because only two different letters are used
Quiz key
A smaller file needs less bandwidth and takes less time to upload or download. Compression never improves quality; lossy compression lowers it. Protecting a file from interception is the job of encryption, and removing viruses is the job of anti-malware software.
Lossy compression permanently removes data, for example by lowering resolution or sample rate, so the original cannot be restored. Rebuilding the file exactly describes lossless compression. Storing runs as a count and value is run length encoding, a lossless method. Splitting into packets is about data transmission, not compression.
If any data in the spreadsheet were lost, a mark could be changed, so it must be rebuilt exactly: lossless. A photo, a recording and a video can lose a little detail without people noticing, so lossy compression is acceptable for them.
Pixels 1 to 3 are white, 4 to 8 black and 9 to 10 white, so the runs are 3W 5B 2W. 5W 5B adds the two white runs together, which loses where they are. 3B 5W 2B swaps the colours. 3W 5B misses the final run, so the image could not be rebuilt.
The original has 18 characters = 18 bytes. The runs are 10W 2B 6W: 3 pairs = 6 bytes. 18 − 6 = 12 bytes saved. 6 is the size of the compressed data, not the saving. 15 counts only 1 byte per run. 3 is the number of runs.
No character is next to a copy of itself, so each is a run of 1: 1A 1B 1A 1B 1A 1B 1A 1B, which is 16 bytes, twice the original. RLE does not spot repeating patterns such as AB. RLE does change text when it encodes it. Knowing only which letters appear is not enough to rebuild the text, so it cannot shrink to 2 bytes.
What to project
The student lesson embeds these tabs. Open them full screen on the projector; every slider has a drag handle on the stage.
Slides for this lesson
A projectable deck for every pack is on the way. Until then, present the student lesson full screen: its sections, figure and lab tabs follow the same order as the plan above.