The shape of the lesson
By the end of the lesson, learners can
- Lossy or lossless?: In the lab, try the lossy mode on the image and turn the amount of compression up.
- Run-length encoding: Switch the lab to RLE and encode the image row by row.
- Compressing each type of file: The syllabus expects you to say how text, bitmaps, vectors and sound can each be compressed.
- Why: less storage, less bandwidth, faster transmission.
- Lossless: original rebuilt exactly (RLE, dictionary methods); for text, programs and critical data.
- Lossy: data permanently removed (perceptual coding, lower resolution or colour depth); for media.
- RLE: count and value for each run; only saves space when there are long runs.
One picture every idea returns to
Compression reduces file size so files need less storage and less bandwidth, and are transmitted faster. Lossless compression reduces the size with no loss of data: the original is rebuilt exactly. Lossy compression permanently removes data, usually detail that human senses notice least, giving much smaller files. Run-length encoding (RLE) is lossless: each run of identical values is replaced by a count and the value.
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.. Images, sound and video files are huge, and every one of them has to be stored and sent somewhere. 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: Lossy or lossless? | In the lab, try the lossy mode on the image and turn the amount of compression up. Project tab 5 of the lab (Lossless and lossy compression) and let a student drive it while the class predicts. | Whole class, then pairs |
| 13 to 21 min | Teach and check: Run-length encoding | Switch the lab to RLE and encode the image row by row. Project tab 5 of the lab (Run-length encoding) and let a student drive it while the class predicts. Model the worked example Text on the board, one line at a time. Your turn: Encode GGGGGGGGHHHHKKKKKKKKKKKK with RLE and give the saving if every count and character takes 1 byte. | Pairs |
| 21 to 30 min | Teach and check: Compressing each type of file | The syllabus expects you to say how text, bitmaps, vectors and sound can each be compressed. | Corners |
| 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, 18 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 Compressing each type of file, 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.
Corners
Put one answer or viewpoint in each corner of the room. Students move to the corner they agree with, justify the choice to a partner there, then hear one voice from each corner before the reveal.
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 |
|---|---|
| A justification needs a reason linked to the scenario. "Lossy because it is smaller" earns less than "lossy, because the photo only needs to load quickly on a web page and the lost detail will not be noticed". | Return to Lossy or lossless?: ask a pair to state the correct version and show it on the lab before moving on. |
| Never suggest lossy compression for a text file or program. | Losing even one character changes the meaning, and a program would no longer run. |
Lossy and lossless compression, run-length encoding: worksheet
6 questions, 18 marks. Written in the style of the papers; no past paper question is reproduced.
Explain why files are often compressed before they are sent across the internet.
A text file contains XXXXXXYYZZZZZZZZZW. Each character and each count is stored in 1 byte. (a) Show the result of run-length encoding. (b) Calculate the number of bytes saved.
A music streaming service and a hospital both need to compress image and sound files. Justify the type of compression each should use.
Describe how a sound file can be compressed using lossy compression.
Explain how a text file can be compressed, and why only lossless compression is suitable.
A 1-bit image row is 10101010. It is compressed with RLE, storing each run as a (count, colour) pair. Explain the effect on the size of the data and state what type of image RLE suits.
Answer key and marking notes
- The file is smaller, so less bandwidth is needed.
- It is transmitted / downloaded faster (also accept: uses less storage on the server).
- (a) 6X 2Y 9Z 1W.
- Original 18 bytes; encoded 4 pairs = 8 bytes.
- (b) 18 − 8 = 10 bytes saved.
- Streaming service: lossy.
- Much smaller files stream quickly with less bandwidth; the removed data is not noticed by most listeners.
- Hospital: lossless.
- Medical images and recordings must be restored exactly, as lost detail could affect a diagnosis.
- Perceptual coding / psychoacoustics is used.
- Frequencies outside the range of human hearing are removed.
- Quieter sounds that are masked by louder sounds at the same time are removed (also accept: reduce the sampling rate or resolution).
- Runs of repeated characters can be replaced by a count and the character (RLE).
- Repeated words or phrases can be replaced by short codes, with a dictionary of codes stored in the file.
- Lossless is needed because every character must be restored exactly; losing any would change the meaning.
- Every run has length 1, so the row becomes 8 pairs: (1,1)(1,0)(1,1)(1,0)(1,1)(1,0)(1,1)(1,0).
- 16 values are stored instead of 8, so the data gets larger.
- RLE suits images with large areas of the same colour (long runs), such as simple diagrams or logos.
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 statement describes lossless compression?
- AThe file is made smaller and the original data can be rebuilt exactly
- BDetail that people are unlikely to notice is permanently removed
- CThe file is always reduced to the smallest possible size
- DThe resolution of the image is reduced so fewer pixels are stored
Which file must be compressed with a lossless method?
- AA spreadsheet of students' exam marks
- BA holiday photograph for a social media post
- CA music track for a streaming service
- DA video trailer embedded on a website
The string WWWWWWBBBWWWWWWWW is compressed with run-length encoding. Each count and each character is stored in 1 byte. How many bytes are saved?
- A11
- B6
- C14
- D9
A row of a black-and-white bitmap is stored with run-length encoding as the (count, colour) pairs 3 0, 5 1, 2 0. Which row of pixels does this decode to?
- A
0001111100 - B
1110000011 - C
000111110 - D
00011111000
The string ABCABCAB is compressed with run-length encoding, storing each count and each character in 1 byte. What is the result?
- A16 bytes, 8 more than the original
- B8 bytes, the same as the original
- C3 bytes, a saving of 5 bytes
- D6 bytes, a saving of 2 bytes
How does perceptual coding, as used in MP3 files, reduce the size of a sound file?
- AIt removes frequencies outside the range of human hearing and quiet sounds masked by louder ones
- BIt replaces runs of identical samples with a count and a value, so no data is lost
- CIt increases the sampling rate so that each sample needs fewer bits
- DIt stores the waveform as a drawing list of curves that can be rescaled
Quiz key
Lossless compression removes only redundancy, so decompressing restores the original bit for bit. Removing detail people will not notice describes lossy compression, which usually gives smaller files than lossless, and lowering the resolution permanently discards data, which is also lossy.
Every number in the spreadsheet must be recovered exactly, so only lossless compression is acceptable. A photo, a streamed music track and a web video are for people to see or hear, where a small loss of quality is not noticed and the smaller file loads faster, so lossy compression is suitable.
The runs are 6 W, 3 B and 8 W, encoded as 6W 3B 8W: 3 pairs = 6 bytes. The original is 17 bytes, so 17 − 6 = 11 bytes are saved. 6 is the size of the encoded data, not the saving; 14 counts each run as a single byte; 9 wrongly merges the two runs of W into one run of 14.
Three 0s, then five 1s, then two 0s gives 0001111100 (10 pixels). 1110000011 swaps the colours, 000111110 ends with only one 0 instead of two, and 00011111000 has three 0s at the end instead of two.
No two neighbouring characters are the same, so there are 8 runs of length 1: 1A 1B 1C 1A 1B 1C 1A 1B, which is 16 bytes, double the original 8. RLE cannot detect the repeating pattern ABC, so the answers that store the pattern once (3 or 6 bytes) are wrong, and the encoded data is not the same size as the original.
Perceptual coding discards sounds that human ears cannot hear or would not notice, so the data is lost permanently but quality seems almost unchanged. Replacing runs with counts is run-length encoding, which is lossless and rarely helps with sound. Raising the sampling rate makes files bigger, and a drawing list is how vector graphics are stored.
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.