OCR GCSE COMPUTER SCIENCE · J277 · PAPER 1
Compression: shrink the data
Why files are squeezed, the two ways to do it, and how to choose. Plus a Block A recap.
Paper 1 · Lesson 7
Les van Computing
In deze les zitten 25 slides, met interactieve quizzen en tekstslides.
OCR GCSE COMPUTER SCIENCE · J277 · PAPER 1
Compression: shrink the data
Why files are squeezed, the two ways to do it, and how to choose. Plus a Block A recap.
Paper 1 · Lesson 7
Lesson 7 of the J277 series, Paper 1, section 1.2 (memory and storage: compression). This is the last lesson of Block A, so it ends with a recap of lessons 1 to 7.
Device-free: show the slide; pupils write the title and date.
Cover photo: yasin hemmati / Unsplash, shown as a hologram.
00 · MISSION · BY THE END OF THIS LESSON
By the end of this lesson you can…
01 Explain why files are compressed.
02 Describe lossy and lossless compression, with examples of each.
03 Choose the right type of compression for a scenario and justify it.
Read the three outcomes. Outcome 3 is the one OCR examines most: a scenario, then "which type and why".
Device-free: pupils copy the outcomes and tick each one at the end.
02 · CHECK · DO NOW (LESSON 6)
Warm up: characters, images and sound
1 How many characters can 7-bit ASCII represent?
2 Give one reason Unicode is used instead of ASCII.
3 An image is 100 × 100 pixels with a colour depth of 8 bits. File size in KB?
4 A 2-second sound: sample rate 8,000 Hz, bit depth 8. File size in KB?
▮ TERMINAL // do_now_answers
1 27 = 128
2 more characters: other
languages, symbols, emoji
3 100 × 100 × 8 = 80,000 bits
÷ 8 ÷ 1000 = 10 KB
4 8,000 × 8 × 2 = 128,000 bits
÷ 8 ÷ 1000 = 16 KB
Retrieval from lesson 6. Give 4 minutes, then click to reveal the answers line by line.
7 bits gives 2 to the power 7 = 128 characters.
Unicode uses more bits per character, so it can represent many more characters, including other languages' alphabets, symbols and emoji.
100 × 100 = 10,000 pixels. × 8 = 80,000 bits. ÷ 8 = 10,000 bytes. ÷ 1000 = 10 KB.
8,000 × 8 = 64,000 bits per second. × 2 = 128,000 bits. ÷ 8 = 16,000 bytes. ÷ 1000 = 16 KB.
(All calculations checked twice.)
Misconception: forgetting to divide by 8 to turn bits into bytes.
Device-free: questions on the board; mini whiteboards.
Recap of lesson 6: which of these is metadata for an image?
The colour code of each pixel
The number of bits per sound sample
The ASCII code for each letter
The width and height in pixels
Answer: the width and height in pixels. Metadata is data about the file, such as width, height and colour depth, so the computer can display the image correctly. The colour codes are the image data itself.
Device-free: students hold up A, B, C or D cards. Image credit: Christian Lue / Unsplash
01 · LEARN · MISSION BRIEFING
Why compress a file?
LESS STORAGE
Smaller files take up less space on a device or a server.
FASTER TRANSFER
Smaller files send and download faster and use less bandwidth.
STREAMING
Music and video can play straight away with less buffering.
SYSTEM VOICE
Mission update. Files are getting too big. Your task: shrink them. Compression reduces file size, so files take up less storage space and travel faster across a network.
Click play for the system voice briefing. The words are also on the slide: "Mission update. Files are getting too big. Your task: shrink them. Compression reduces file size, so files take up less storage space and travel faster across a network."
Link to lesson 6: a 10-second sound clip was 882 KB and a modest photo 6 MB. Multiply by thousands of photos or songs and storage and download times grow quickly.
Three reasons to compress: less storage space; faster transfer over a network and less bandwidth used; streaming starts sooner with less buffering. Also: email services limit attachment sizes.
Device-free: read the briefing aloud; pupils list two times they have waited for a file to send or download.
01 · LEARN · COMPRESSION
Same file, fewer bits
Compression uses an algorithm to reduce the size of a file.
There are two types:
Lossy: some data is removed for good.
Lossless: no data is lost; the original can be rebuilt.
Define compression: reducing the size of a file using an algorithm, so it needs fewer bits to store. Introduce the two types; the next slides teach each one.
Ask: if you could make a photo half the size, what would you be willing to lose? (Tiny details nobody notices: that is the idea behind lossy.)
Device-free: pupils write the definition and the two types as headings in their books. Image credit: Adi Goldstein / Unsplash
01 · LEARN · LOSSY
Lossy: remove what you won't miss
Lossy compression permanently removes data, usually detail people are unlikely to notice.
The original file cannot be restored, but the file gets much smaller.
Examples: JPEG photos, MP3 music.
Lossy compression permanently removes some data from the file. A JPEG might merge very similar colours or drop fine detail; an MP3 removes sounds that people cannot easily hear. The result is a much smaller file with slightly lower quality.
Advantages: much smaller files; quicker to download and stream; less storage. Disadvantages: quality is reduced; the original cannot be recovered; compressing again and again loses more each time.
Misconception: lossy does not mean the file is broken or unusable; the loss is chosen to be hard to notice.
Device-free: pupils write one advantage and one disadvantage of lossy compression. Image credit: Grooveland Designs / Unsplash
01 · LEARN · LOSSLESS
Lossless: nothing is thrown away
Lossless compression finds patterns and stores them more efficiently. No data is lost.
The original file can be rebuilt exactly, bit for bit. Files shrink less than with lossy.
Examples: PNG images, ZIP files.
▮ TERMINAL // lossless_demo
1 // store repeats once
2 in = AAAAAABBBCCCC (13)
3 out = 6A3B4C (6)
4 rebuild → AAAAAABBBCCCC
5 match = True
Used where every bit matters: text, program files, data.
Lossless compression reduces file size without losing any data: it stores patterns more efficiently, and decompressing gives back exactly the original file.
Terminal (click per line): one simple lossless idea is to store each run of repeated characters once with a count. AAAAAABBBCCCC is 13 characters (6 A, 3 B, 4 C); 6A3B4C is 6 characters. Rebuilding gives exactly the same 13 characters. The name of this method is not required for J277; the point is that nothing is lost.
Use lossless for text documents, program files, spreadsheets and anything where a single changed bit would cause an error. Examples: PNG (images), ZIP (any files).
Misconception: lossless files are not always small; they shrink less than lossy files.
Device-free: write AAAAAABBBCCCC on the board; pupils compress and then decompress it.
01 · LEARN · LOSSY VS LOSSLESS
Side by side
LOSSY
Data removed permanently
Original cannot be restored
Much smaller files
JPEG, MP3: photos, music, streaming
LOSSLESS
No data lost
Original rebuilt exactly
Smaller files, but less reduction
PNG, ZIP: text, programs, data
SYSTEM VOICE · KEY DEFINITIONS
Lossy compression permanently removes some data, so the original file cannot be restored. Lossless compression keeps all of the data, so the original file can be rebuilt exactly.
Click play for the system voice. Words on the slide: "Key definitions. Lossy compression permanently removes some data, so the original file cannot be restored. Lossless compression keeps all of the data, so the original file can be rebuilt exactly."
Pupils copy the comparison. Stress the exam keywords: "permanently removes", "cannot be restored", "rebuilt exactly", "no data is lost".
Device-free: read the definitions aloud; pupils draw the two-column comparison in their books.
Which of these file formats uses lossy compression?
JPEG
PNG
ZIP
Answer: JPEG. JPEG uses lossy compression for photos. PNG and ZIP are lossless.
Follow-up question: name a lossy format for sound (MP3).
Device-free: pupils write the answer on mini whiteboards. Image credit: James Thompson / Unsplash
03 · DEBUG · SPOT THE MISTAKE
One line in Ravi's notes is wrong
▮ TERMINAL // ravi_notes.txt
1 lossless: no data lost
2 lossy: data removed for good
3 MP3 music = lossy
4 Python program = lossy, smaller
5 PNG image = lossless
Line 4. A program must use LOSSLESS compression. Lossy removes data, so lines of code would be lost or changed and the program would not run. Every bit of a program file matters.
Ask: what would happen if a single bit of the file changed? Tap the marker to check.
Exam tip: say the type AND why it suits the file, not just the type.
Give a minute to find the mistake before tapping the marker.
Answer: line 4. Program files (and text, spreadsheets, databases) must use lossless compression: if any data were removed, the program would contain errors and would not run correctly. Lines 1, 2, 3 and 5 are correct.
Device-free: copy the five lines onto the board; pupils write the wrong line number and the correction.
Lossy or lossless? Drag each file to the best type.
LOSSY
LOSSLESS
Python game file
Holiday photo for a website
Spreadsheet of bank payments
Song for a music streaming app
Live video call
English essay document
Answers. Lossy: holiday photo for a website, song for a music streaming app, live video call (small size and speed matter more than perfect quality; small losses are hard to notice). Lossless: Python game file, spreadsheet of bank payments, English essay document (every character or number must be exactly right).
Discussion: a photographer editing a picture to print might keep a lossless copy, so the "best" type depends on the purpose. Ask pupils to justify, not just sort.
Device-free: read each file aloud; pupils show L for lossy or LL for lossless on mini whiteboards.
01 · LEARN · CHOOSING THE TYPE
Ask one question first
Must the file come back exactly the same?
Yes (text, programs, data): use lossless.
No, a small drop in quality is fine and size or speed matters most (photos, music, video): use lossy.
The deciding question: does every bit need to come back exactly? If yes, lossless. If a small, hard-to-notice loss of quality is acceptable and a smaller file, faster download or smoother streaming matters more, lossy.
Exam structure for "which type and why" questions: name the type, give a reason linked to the scenario (for example "faster to download for listeners"), and say why the drawback does not matter (for example "a slight loss in quality would not be noticed").
Device-free: pupils write the deciding question at the top of a page and two examples under each answer. Image credit: Brecht Corbeel / Unsplash
Kwame is emailing his finished Python game to a friend. Which compression should he use?
Lossy, because the file will download faster
Lossless, because every bit of code must stay the same
Lossy, because nobody will notice missing code
Answer: lossless, because every bit of code must stay the same. If any data were removed, the game would have errors and would not run.
The first choice gives a true fact about lossy files (they are smaller and faster) but ignores the effect on the program. The third choice is wrong: missing code stops a program working.
Device-free: pupils hold up 1, 2 or 3 fingers. Image credit: Chris Ried / Unsplash
Give one advantage and one disadvantage of using lossy compression for a photo.
Good answers. Advantage: much smaller file, so it takes less storage space, uploads and downloads faster and uses less bandwidth. Disadvantage: some data is permanently removed, so the quality is lower and the original photo cannot be restored.
Share two or three answers on the board and improve one together so that both parts are linked to the photo.
Device-free: pupils write their answer on paper; collect three and read them out.
To open the file, expand each count back into the full run
Spot a value that repeats several times in a row
Read the data from the start
Carry on to the end of the data
Store that value once, with a count of how many times it repeats
Lossless compression of repeated data. Put the steps in order.
Correct order: read from the start; spot a repeated run; store the value once with its count; carry on to the end; to open the file, expand each count back into the full run.
This is the idea in the lossless demo earlier: because every run can be rebuilt exactly, no data is lost.
Device-free: students number the five steps, then compress AAAABBBCCD (answer 4A 3B 2C 1D).
Complete the summary.
Compression reduces the size of a file, so it uses less storage and transfers faster. Lossy compression permanently removes data, for example in JPEG photos and MP3 music. Lossless compression lets the original file be rebuilt exactly, so it is used for text and programs, for example in PNG and ZIP files.
Answers in order: Compression, Lossy, JPEG, Lossless, exactly, ZIP. Distractors: Unicode, roughly, resolution.
Device-free: paragraph on the board with gaps and the word bank; pupils write the six missing words.
02 · CHECK · BLOCK A RECAP
Block A: inside the machine
L1 · THE CPU
Fetch–execute cycle; PC, MAR, MDR, accumulator; ALU and CU.
L2 · PERFORMANCE
Clock speed, cores and cache; embedded systems.
L3 · MEMORY
RAM, ROM, virtual memory; magnetic, optical and solid state storage.
L4 · UNITS
Bit to petabyte (× 1000); denary and binary conversion.
L5 · BINARY + HEX
Binary addition, overflow, binary shifts, hexadecimal.
L6 · DATA
ASCII, Unicode; resolution, colour depth; sample rate, bit depth.
L7 · COMPRESSION
Why compress; lossy (JPEG, MP3) and lossless (PNG, ZIP).
NEXT · BLOCK B
Connected and secure: networks, the internet and protocols.
Block A covered OCR J277 sections 1.1 (systems architecture) and 1.2 (memory and storage). Ask pupils to rate each card red, amber or green for how confident they feel; these ratings guide revision before the Block A assessment.
Device-free: pupils draw eight boxes and write one key fact they remember for each lesson before the card is discussed.
Type one key word from Block A that you could explain to a friend.
Show the answers as a word cloud: the biggest words are the ones the class feels most sure of. Pick a small word from the cloud and ask a volunteer to explain it.
Device-free: students write their word on a mini whiteboard and hold it up; the teacher picks three to explain.
02 · CHECK · BLOCK A QUICK-FIRE
Six questions, one from each lesson
1 Which register holds the address of the next instruction?
2 Give one factor that affects CPU performance.
3 Which is volatile: RAM or ROM?
4 How many bytes are in 1 KB?
5 Convert binary 10110110 to hex.
6 Which type of compression does ZIP use?
▮ TERMINAL // block_a_answers
1 PC (program counter)
2 clock speed / cores / cache
3 RAM
4 1000
5 1011 0110 = B6
6 lossless
Quick-fire recap of Block A. Pupils answer all six, then click to reveal one answer at a time.
The program counter (PC) holds the address of the next instruction to be fetched.
Clock speed, number of cores, or cache size.
RAM is volatile (contents lost when the power is off); ROM is non-volatile.
OCR uses 1 KB = 1000 bytes.
Split into nibbles: 1011 = 11 = B, 0110 = 6, so B6. Check: 10110110 = 128 + 32 + 16 + 4 + 2 = 182, and B6 = 11 × 16 + 6 = 182.
ZIP uses lossless compression.
Device-free: read the questions aloud; pupils write answers 1 to 6 and self-mark.
Block A: drag each description to the term it describes.
RAM
PC
UNICODE
LOSSY
Holds the address of the next instruction
Removes data permanently to make a file smaller
Volatile: loses its contents when the power is off
Character set with codes for many languages and emoji
Answers: RAM = volatile, loses its contents when the power is off; PC = holds the address of the next instruction; Unicode = character set with codes for many languages and emoji; lossy = removes data permanently to make a file smaller.
Device-free: students match the four by drawing lines in their books.
EXAM · Sam records a podcast and wants to put it online for people to stream. Explain whether Sam should use lossy or lossless compression. [3 marks]
Exam-style question, 3 marks. Give 4 minutes. The model answer is on the next slide.
Mark scheme (1 mark each, max 3): Lossy (1). Smaller file, so it downloads or streams faster, with less buffering, and uses less bandwidth or storage (1). The small loss of quality is unlikely to be noticed, especially for speech, so it is an acceptable trade-off (1). A lossless answer gains credit only if justified (for example the audio must be kept at full quality for editing); the expected answer is lossy.
Device-free: pupils answer on paper, then peer-mark with the next slide.
04 · EXAM · MODEL ANSWER
Model answer: lossy
Sam should use lossy compression.
It makes the podcast file much smaller, so listeners can stream it with less buffering and it uses less bandwidth.
Some data is removed, but the small drop in quality is unlikely to be noticed in speech, so it is worth it.
MARK SCHEME
1 mark: lossy
1 mark: smaller file, faster to stream or download
1 mark: quality loss not noticeable or acceptable
Click to reveal the model answer one sentence at a time. Each sentence earns one mark: the type, a benefit linked to streaming, and why the drawback is acceptable.
Common weak answer: "Lossy because it is smaller." This earns 1 or 2 marks: it names the type and a benefit but does not explain why the loss of quality does not matter here.
Device-free: read the model answer aloud; pupils underline the three mark-earning parts in their own answer.
Exit check: lossy or lossless, how sure are you?
Very confident: I can choose and explain why
Fairly confident: I can choose but the why is hard
Not yet: I mix them up
Anonymous exit poll. If many pupils choose "not yet", revisit the deciding question ("must the file come back exactly the same?") at the start of the next lesson.
Device-free: thumbs up, sideways or down.
05 · NEXT · KEEP GOING
Keep going
Isaac Computer Science
Free online lessons and questions. Look up compression and the other Block A topics.
BBC Bitesize
GCSE Computer Science, OCR: revise data representation and compression, then try the test.
OCR past papers
J277/01 papers and mark schemes on the OCR website. Practise the Block A questions.
Next lesson: Block B begins with networks.
Point pupils to independent practice. Isaac Computer Science (isaaccomputerscience.org) and BBC Bitesize (bbc.co.uk/bitesize) are free. OCR past papers and mark schemes for J277/01 are on the OCR website (ocr.org.uk).
Homework idea: make a one-page Block A revision sheet with one key fact and one worked example from each of lessons 1 to 7.
Device-free: pupils copy the three sources and the homework task.