Skip to main content
AP CSP course

C12 · Topic 2.2 · 40 minutes · DAT-1.D

Choosing a compression trade-off

By the end you can:

  • Choose a recovery requirement for a purpose.
  • Explain what lossy encoding discards.
  • Distinguish compression from confidentiality.

Before this lesson: topics 2.1.

Lossless compression
An encoding that allows exact reconstruction of the original data.
Lossy compression
An encoding that discards distinctions so exact reconstruction is not generally possible.

Understand

A lossy scheme intentionally discards some information, such as merging nearby colours or removing sound detail. Several different originals can produce the same encoded result, so the decoder cannot determine exactly which original occurred. Visual similarity does not prove bit-for-bit recovery.

A suitable choice depends on requirements. A small thumbnail may permit a stated loss for faster transfer, whereas programme source or exact records may require lossless recovery. Compression and encryption solve different problems: a standard decoder can recover losslessly compressed data without that making it confidential.

Worked example

A fictional thumbnail encoder maps colour values 100,101 and 102 to 101 without storing which original occurred.

  1. Original 100 and original 102 both produce 101.
  2. A decoder seeing 101 cannot distinguish those originals from the encoding alone.
  3. The scheme may suit an approximate preview, but does not satisfy a requirement to preserve every original stored value.

Explore each concept

Choose a concept, change its inputs and follow the explanation. Each example models the stated rule or scenario; completing it is practice rather than evidence of mastery.

  • Dictionary reconstruction
  • Lossy collisions
  • Purpose and recovery requirements
Open this example on its own

Change it · step through · explain

Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.

Ready · Make a prediction

Ready to explore: Decode losslessly or discard information
  1. EncodingdictionaryWaiting
  2. Original messageteam go teamWaiting

Ready to explore: Decode losslessly or discard information

Why: Change an input, predict the first effect, then advance one step.

Try this: Change one input or choose another listed case. Predict the effect, reset and compare the states and governing rule.

Step through and experiment

Change it · step through · explain

Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.

Ready · Make a prediction

Ready to experiment
  1. Input 120Waiting
  2. Input 212Waiting
  3. Input 310Waiting

Ready to experiment

Why: Predict the first change, then advance one step.

Try this: Make payload + dictionary equal the original, then change it by one byte.

Check a misconception

Claim: A picture that looks the same must have been compressed losslessly.

Appearance and exact data recovery are different requirements.

Guided practice

Explain why this colour mapping is lossy using two distinct originals.

Work with a partner. Make a prediction, compare your reasoning, then identify the rule that supports your answer.

Independent transfer

Choose methods for a programme source file and a low-bandwidth preview with explicitly acceptable small detail loss.

Exit check

What extra mechanism is needed if observers must not read the compressed content?

Write your reasoning before comparing with a classmate. If your teacher assigned this task, submit it through My classes to save your work and receive feedback.

Check yourself

  1. Question 1 of 2Which use most directly requires exact recovery?

    Select one answer.

  2. Question 2 of 2Which TWO statements are correct?

    Select exactly two answers (0 of 2 selected).

Your practice so far

Check an answer to see its rationale.

Teacher guidance and scoring