Study Guide Instructor view
Data Compression
Teaching notes for Lesson 1.10, with controls for presenting it.
Keep this page on your own screen. Share only the lesson window. The lesson window holds no teaching notes, so sharing it cannot show them.
Presenting
- Open the lesson in its own window and share that window, not this one.
- Use Next and Previous here, or the lesson’s own, to move through the lesson. Next reveals one thing at a time: the next idea, or the answer to the question on screen, then the next step. Previous takes the last reveal back. The line below says what is on screen and what Next will show.
- Reveal hints and answers when the class is ready, and reset a demonstration before using it again.
The controls need JavaScript and a browser that supports BroadcastChannel. Without them, open the lesson in presentation mode and use its own controls.
The two windows talk to each other only inside this browser, on this device. Nothing is sent to a server, and no account is needed. A second device (a phone or another tablet) cannot follow the lesson window yet.
Now on the lesson window
- On screen
- Next teaching point
Guidance for this point
Lesson plan
- Level
- Intermediate
- Time
- About 60 minutes; the steps below add up to 60
Learners invent run-length encoding for themselves by shortening a bead order over the phone, then practise it on text and on rows of pixels and discover that it can make some data longer. They work out why compression matters (storage, bandwidth, transmission time), separate lossless from lossy by shrinking a photograph, and choose and justify a method for a text file, a map and a recording. The lesson ends with an explanation of RLE against lowering colour depth.
Objectives
- Explain why files are compressed: less storage space, less bandwidth and a shorter transmission time
- Compress and decompress a line of text and a row of pixels using run-length encoding
- Explain how lossless compression differs from lossy compression
- Describe how reducing resolution, colour depth, sample rate or sample resolution makes a file smaller and what is lost
- Choose lossy or lossless compression for a situation, and justify the choice
Before the lesson
- The bead pattern on the board as coloured circles or letters (W and B), 16 long.
- Mini whiteboards for encoding and decoding runs; insist on count first, then character.
- A reminder of colour depth and resolution from the images lesson, and of sample rate and resolution from the sound lesson.
- Optional: a text file, a bitmap and a short recording on a screen, to link ‘type of data’ to ‘type of compression’.
Steps
Introduction Opening
On the lesson window now
On screen: the lesson’s title, module and number; Next adds its objectives and key terms, as the lesson page lists them; Next again begins the first step.
Objectives on screen
- Explain why files are compressed: less storage space, less bandwidth and a shorter transmission time
- Compress and decompress a line of text and a row of pixels using run-length encoding
- Explain how lossless compression differs from lossy compression
- Describe how reducing resolution, colour depth, sample rate or sample resolution makes a file smaller and what is lost
- Choose lossy or lossless compression for a situation, and justify the choice
Purpose: Learners invent run-length encoding for themselves by shortening a bead order over the phone, then practise it on text and on rows of pixels and discover that it can make some data longer. They work out why compression matters (storage, bandwidth, transmission time), separate lossless from lossy by shrinking a photograph, and choose and justify a method for a text file, a map and a recording. The lesson ends with an explanation of RLE against lowering colour depth.
1. A shorter message Think 5 min
On the lesson window now
Purpose: Learners propose a shorter message that loses nothing, before run-length encoding is named.
Ask
- How could Dalia say the 16-bead pattern in far fewer words so that the supplier still gets every bead right?
- How do you know nothing is lost?
Responses to expect
- 8 white, 4 black, 4 white: six words instead of sixteen
- The supplier can rebuild the exact pattern from the counts
Misconceptions to challenge
- A learner may believe: “The shorter message must lose some information, or it would not be shorter.” Respond: Here nothing is lost: ask the class to rebuild the pattern from ‘8 white, 4 black, 4 white’.
On the board or with the pen
- Write the 16 beads, then bracket the runs with the pen and write the count above each.
Checking understanding: Pairs swap messages and rebuild each other’s pattern.
English as an additional language
- Check bead, pattern and supplier; hold up two colours of counter.
Discussion pause: Silent thinking for thirty seconds; learners then write their own shorter message.
In the lesson window
- Think it through: How could Dalia say this pattern in far fewer words, so that the supplier still gets every bead right?
2. Run-length encoding on text Discover 10 min
On the lesson window now
Purpose: Learners practise encoding and decoding text with the count first, and discover that RLE can make data longer.
Ask
- Encode AAABCCCC. What do you write for a run of one?
- ABAB has 4 characters. How many characters does its RLE form have, and what does that tell you?
Responses to expect
- 3A1B4C
- 8 characters, twice as many; RLE helps only when there are long runs
Misconceptions to challenge
- A learner may believe: “Compression always makes a file smaller.” Respond: ABAB becomes 1A1B1A1B, which is longer. A method works well for some data and badly for others.
- A learner may believe: “A run of one needs no count.” Respond: Without the count the decoder cannot tell a run of one from a character in a different position; always write the count.
- A learner may believe: “The order of count and character does not matter.” Respond: This lesson always writes the count first, so the decoder reads count, then character.
On the board or with the pen
- Work 4A3B2C1D by finding the runs first with brackets, then writing each count and character.
What learners should notice
- Decoding gives back exactly the original: nothing is lost.
Checking understanding: The rle-encode-text and rle-decode-text tables.
Depending on the answers
- If learners write the character before the count: ask them to decode their own answer using the count-first rule.
- If learners are secure: ask for a string that is exactly the same length after encoding (for example AABB, which becomes 2A2B).
Support
- Provide a boxed template: ___ ___ ___ for count, character pairs.
English as an additional language
- Check run, count and decode; use the word ‘run’ for a stretch of identical items.
In the lesson window
- Think it through: Look at the last row. ABAB has 4 characters. How many characters does its run-length encoded form have? What does this tell you about when RLE is useful and when it is not?
3. Why make a file smaller? Predict 8 min
On the lesson window now
Purpose: Learners calculate time saved and name the three results of a smaller file: less storage, less bandwidth, shorter transmission time.
Ask
- 8 MiB over a connection of 1 MiB per second. How long does it take, and what about 2 MiB?
- A 12 MiB file is compressed to 3 MiB. How much shorter is the transmission time?
Responses to expect
- 8 seconds and 2 seconds
- 9 seconds shorter: 12 − 3
Misconceptions to challenge
- A learner may believe: “3 seconds shorter, because the compressed file takes 3 seconds (time-saved option A).” Respond: That is the time for the compressed file, not the time saved. How long did the original take, and what is the difference?
- A learner may believe: “4 seconds shorter, because the file is four times smaller (option B).” Respond: Four times smaller means one quarter of the time, but not 4 seconds. Work out both times and subtract.
- A learner may believe: “Compression only saves time, not space.” Respond: A smaller file also takes less storage on every device that keeps a copy, and less of the connection.
On the board or with the pen
- Write the three results as three bullet points next to the 8 s and 2 s working.
What learners should notice
- Bandwidth is the amount of data a connection can carry in a given time.
Checking understanding: The time-saved question.
Depending on the answers
- If learners compute the new time but not the saving: underline ‘how much shorter’ and ask for a subtraction.
English as an additional language
- Check bandwidth and transmission; draw a pipe that carries 1 MiB each second.
In the lesson window
- Think it through: How long does it take to send the file? If the same video were compressed to 2 MiB, how long would it take then? What else gets smaller, besides the time?
- Apply it: A file of 12 MiB is compressed to 3 MiB, and sent over a connection that carries 1 MiB each second. How much shorter is the transmission time?
4. Keeping everything or letting some go Predict 10 min
On the lesson window now
Purpose: Learners predict whether reducing colour depth can be undone, and then meet lossy and lossless compression with examples.
Ask
- A photo is 1024 × 768 at 24 bits. What is the new size at 8 bits? Could she get the 24-bit colours back?
- A sound is compressed by lowering its sample resolution from 16 to 8 bits. Which statement is correct?
Responses to expect
- 0.75 MiB, a third of the size; no, the colour information has been thrown away
- The file is smaller and the original cannot be restored, because detail was permanently removed
Misconceptions to challenge
- A learner may believe: “The original 16-bit sound can be restored exactly (can-undo-lossy option A).” Respond: Lowering the resolution rounds each sample to fewer levels. Once rounded, where is the extra detail stored?
- A learner may believe: “The file stays the same size, because only the quality changes (option C).” Respond: Each sample now takes 8 bits instead of 16. What does that do to the total number of bits?
- A learner may believe: “Lossy means the file is damaged.” Respond: Lossy is a deliberate method that removes data for good in return for a much smaller file.
On the board or with the pen
- Fill in the lossy and lossless table with the example of each and the question: can the original be got back?
What learners should notice
- Lossy examples: lower resolution, colour depth, sample rate or sample resolution. Lossless example: RLE.
Checking understanding: The can-undo-lossy check.
Depending on the answers
- If learners think any compression can be undone: ask which stored values still exist after the colour depth change.
Stretch
- Why is the size of a file after lowering the sample rate half of the original at exactly half the rate?
Discussion pause: Silent thinking about whether she could get the colours back.
In the lesson window
- Think it through: A pupil has a photo of 1024 × 768 pixels with a colour depth of 24 bits (2.25 MiB). To make it smaller she reduces the colour depth to 8 bits. What is the new size? Could she get the original 24-bit colours back from the smaller file?
- Check your understanding: A sound is compressed by lowering its sample resolution from 16 bits to 8 bits. Which statement is correct?
5. Run-length encoding on a picture Apply 10 min
On the lesson window now
Purpose: Apply RLE to rows of pixels, decode a row, and notice when long runs make it effective.
Ask
- The first row is WWWBBWWW. Write it as runs.
- A row is stored as 2W1B1W3B1W. Which row is it?
- A row of 64 pixels has 28 white, 8 black and 28 white. What is its RLE?
Responses to expect
- 3W2B3W
- WWBWBBBW
- 28W8B28W
Misconceptions to challenge
- A learner may believe: “The row is BBWBWWWB, with the colours the wrong way round (decode-pixel-row option A).” Respond: The first run is 2W, which is white. Read each pair as a count and then a colour.
- A learner may believe: “The row is WWBWWBBB (option C).” Respond: Check the third pair: 1W is one white pixel, not two. Count the pixels in each run.
- A learner may believe: “64W (long-row option B).” Respond: That would be 64 white pixels. Where do the black pixels appear in it?
- A learner may believe: “28W28W8B (option C).” Respond: The runs are in the wrong order; the black pixels are in the middle.
On the board or with the pen
- Encode the six rows of the house on the board, writing the count of runs beside each.
What learners should notice
- Row 6 has five runs, and its encoding is longer than the 8 pixels.
Checking understanding: The rle-house table, then the decode and long-row checks.
Depending on the answers
- If learners decode with the wrong total: ask them to add up the counts: 2 + 1 + 1 + 3 + 1 should be 8.
Support
- Provide strips of eight boxes for rebuilding the rows.
In the lesson window
- Think it through: The first row of the house is WWWBBWWW. Write it as runs, using the count first.
- Check your understanding: A row of 8 pixels is stored as 2W1B1W3B1W. Which row of pixels is it? (W is white and B is black.)
- Check your understanding: A row of 64 pixels has 28 white pixels, then 8 black pixels, then 28 white pixels. Which is its run-length encoding?
6. Choosing lossy or lossless Explain 13 min
On the lesson window now
Purpose: Learners decide between lossy and lossless for different data, justify the choice, and correct a claim that a lossy change can be undone.
Ask
- Would you accept an essay with a few letters removed? A holiday photo with slightly fewer colours? Explain the difference.
- A bus app sends a route map over a slow connection. The lines must be exactly in the right places. Which method, and why?
- Maya lowers the sample rate and says decompressing will restore the original. What is wrong?
Responses to expect
- A missing letter can change meaning, so lossless; a small loss of colour is acceptable, so lossy may do
- Lossless, such as RLE, because the lines must be exact and the large areas of one colour give long runs
- Lowering the sample rate removes samples for good, so it is lossy and cannot be undone
Misconceptions to challenge
- A learner may believe: “Lossy, reducing the resolution until the file is tiny, because small files are always best (map-app-choice option A).” Respond: Reducing the resolution would blur the thin lines. Is it acceptable for the lines to blur or move?
- A learner may believe: “Maps cannot be compressed (option B).” Respond: The picture has large areas of one colour, which is where RLE works well.
- A learner may believe: “Decompressing always restores the original (mayas-claim option B).” Respond: Decompressing can only restore what was kept. When the sample rate was reduced, were all the samples kept?
- A learner may believe: “Reducing the sample rate makes the file larger (option C).” Respond: A lower sample rate means fewer samples each second: fewer bits.
Checking understanding: The sorting table, then the two apply questions: one choice with reasons, one critique.
Depending on the answers
- If learners choose lossy for a program file: ask what would happen if one instruction changed.
- If learners are secure: ask which method suits a text file and why RLE may not help (few long runs).
Stretch
- Why might a photo not compress well with RLE, even though it has many pixels?
English as an additional language
- Provide the sentence frame: ‘This data needs … compression because …’.
In the lesson window
- Think it through: Would you accept a compressed copy of an essay in which a few letters had been removed to save space? Would you accept a compressed copy of a holiday photo with slightly fewer colours? Explain the difference.
- Apply it: A fictional bus app must send a route map to a phone over a slow connection. Maps are a picture with large areas of a single colour and thin lines. The lines must be exactly in the right places. Which method suits best, and why?
- Apply it: Maya says: “I reduced the sample rate of my recording to make the file smaller. When I decompress it, I will get my original recording back.” What is wrong with Maya’s reasoning?
7. Bring it together Consolidate 4 min
On the lesson window now
Purpose: Learners explain why compression is useful and how RLE differs from lowering colour depth, and encode a final string before the summary.
Ask
- Explain to a friend why compression is useful, and how RLE differs from reducing an image’s colour depth.
- What is AAAAAABBBB after RLE, count first?
Responses to expect
- Smaller file: less storage, less bandwidth, shorter transmission time; RLE is lossless and reversible, lowering colour depth is lossy and cannot be undone
- 6A4B
Misconceptions to challenge
- A learner may believe: “A6B4, with the letters before the counts (rle-six-as option B).” Respond: This lesson writes the count first, then the character.
- A learner may believe: “10AB, with the total (option C).” Respond: The runs have to be kept separate: how many As, and how many Bs?
Checking understanding: Listen for both the three results of compression and the lossless against lossy contrast.
Depending on the answers
- If learners cannot state the difference: begin the next lesson with 4A3B2C1D and with a photo at 8 bits, asking which can be undone.
In the lesson window
- Think it through: Without looking back, explain to a friend why compression is useful, and how run-length encoding differs from reducing an image’s colour depth.
- Check your understanding: What is AAAAAABBBB after run-length encoding, writing the count first?
Lesson recap Closing
On the lesson window now
On screen: the lesson’s objectives again; Next adds the closing question, which asks the class to explain each one in their own words without looking back. It says nothing about what anyone has learnt: use the answers to decide what to revisit.
Points to listen for
- Compression makes a file smaller: less storage space, less bandwidth, shorter transmission time.
- Lossless compression loses nothing permanently; run-length encoding stores a run once with its count (4A3B2C1D) and can be decoded exactly.
- RLE works well on long runs and badly when the values keep changing: ABAB becomes twice as long.
- Lossy compression permanently removes data (lower resolution, colour depth, sample rate or sample resolution); the original cannot be got back.
- Use lossless where every detail must survive; lossy where a small loss is acceptable for a much smaller file.
Consolidation
- Compression makes a file smaller: less storage space, less bandwidth, shorter transmission time.
- Lossless compression loses nothing permanently; run-length encoding stores a run once with its count (4A3B2C1D) and can be decoded exactly.
- RLE works well on long runs and badly when the values keep changing: ABAB becomes twice as long.
- Lossy compression permanently removes data (lower resolution, colour depth, sample rate or sample resolution); the original cannot be got back.
- Use lossless where every detail must survive; lossy where a small loss is acceptable for a much smaller file.