AP Courses AP Biology AP Biology Units AP Human Geography AP HUG Units AP Computer Science Principles AP CSP Units
Practice Daily Practice Practice by Course Practice by Topic Practice Tests
AP Exam Resources AP Exam Dates Registration Fees Scores & Credit What to Bring
Start Practicing → Login Register →

AP Computer Science Principles · Unit 2 · Data

Lossless vs Lossy Compression for AP CSP

Unit 2 · Formats · ~8 min read

Pick PNG, JPEG, ZIP, or MP3 with AP-ready reasoning—perfect rebuild vs smaller files with acceptable loss.

Lossless compression restores every original bit; lossy compression removes detail for much smaller files. AP CSP asks you to match PNG, JPEG, ZIP, and MP3 to scenarios based on content, risk, and bandwidth. Name what is stored, whether any bit change matters, and why smaller size is worth tradeoffs for photos, music, or code archives.

Updated May 21, 2026Reviewed by APScore5 Editorial TeamAP CSP Unit 2 · Data

PNG / ZIP losslessJPEG / MP3 lossyScenario MCQs8 practice items
Step 1LosslessText, code, medical scans.Step 2LossyStreaming photos and music.Step 3TradeoffsName content + risk.Step 4PracticeEight MCQs.
Direct answer

Lossless compression restores every original bit; lossy compression removes detail for much smaller files. AP CSP asks you to match PNG, JPEG, ZIP, and MP3 to scenarios based on content, risk, and bandwidth. Name what is stored, whether any bit change matters, and why smaller size is worth tradeoffs for photos, music, or code archives.

Lossless

When Should You Use Lossless Compression?

Which formats are lossless?

Choose lossless when any change to a bit would matter—source code, tax forms, medical measurements, or UI screenshots with crisp text. ZIP archives for Create Task submissions are everyday lossless examples.

PNG preserves exact pixels, which helps diagrams and slides. FLAC keeps full audio for music editing, though file sizes stay large compared with MP3.

Lossless does not always mean tiny. Highly random data may shrink only a little, yet the rebuild stays perfect.

FormatTypeTypical use
ZIP / GZIPLosslessProject folders, logs
PNGLosslessScreenshots, graphics
FLACLosslessAudio masters

Compare with compression ratios and RLE in the same unit.

Lossy

When Is Lossy Compression Appropriate?

Why use JPEG or MP3?

Lossy formats target human perception. JPEG drops fine color detail in photos; MP3 removes frequencies many listeners cannot hear. Streaming a concert clip over school Wi-Fi is realistic because of lossy codecs.

A music app on your phone stores thousands of songs precisely because lossy compression shrinks each track. The trade is quality versus storage—acceptable for playlists, unacceptable for legal evidence photos.

Re-saving the same JPEG many times compounds artifacts. For class posters, export once at sensible quality instead of repeatedly screenshotting screenshots.

Scenario cue: If the stem mentions “acceptable small errors” for photos or audio, lossy is on the table. If it mentions “exact pixels” or “legal record,” go lossless.

Compare with image bit depth in the same unit.

Tradeoffs

What Tradeoffs Does the Exam Test?

How do you justify a choice?

Strong answers name three pieces: content type, risk if bits change, and storage or bandwidth pressure. Example: “Yearbook photos can be JPEG because small color errors are invisible at print size, and files must fit on a shared drive.”

Weak answers only say “JPEG is smaller.” Add why the loss is acceptable or why it is not.

Create Task write-ups can mention compression when describing large data files. Connecting user impact to format choice shows the computational thinking AP lists in the rubric.

Compare with compression ratio math from the data-compression guide when stems include numbers.

Compare with photo metadata risks in the same unit.

Artifacts

What Are Compression Artifacts?

What does over-compression look like?

Artifacts are visible or audible glitches from aggressive lossy settings—blocky JPEG skies, muddy MP3 cymbals, or rainbow bands around text in photos saved as JPEG.

Zoom into a highly compressed campus photo and you will see 8×8 blocks; that pattern is evidence of lossy algorithms cutting corners for size.

Artifacts differ from random noise. Noise exists in the original scene; artifacts appear only after compression.

Class demo: Save the same portrait at quality 90 and quality 10. Project both on the board and list which details disappeared—skin tones, hair edges, background text.
Exam

How Do You Answer 'Best Format' MCQs?

What keywords hint lossless?

Keywords like legal, medical, text, checksum, or exact pixels point lossless. Words like streaming, playlist, photo library, or satellite time-lapse point lossy.

If two answers are both lossy, pick the one matching the media type—JPEG for still photos, MP3 for music.

Explain in writing responses even when MCQs only demand a letter—practice sentences now so FRQ-style prompts feel familiar.

Work the eight MCQs here, then cross-study metadata when stems mention EXIF or location tags on photos.

Practice

AP-style practice on Lossless vs Lossy Compression

Tap an answer to reveal the explanation. Choices shuffle on load. For a full mixed set, open 50 Unit 2 practice questions.

JPEG is usually:

Q1

Legal contract scan should use:

Q2

MP3 audio compression is:

Q3

PNG screenshots are typically:

Q4

Satellite photos every 30s likely use:

Q5

Lossy choice when:

Q6

Visible blockiness after saving indicates:

Q7

FLAC audio is:

Q8
Before you leave

What you should be able to do now

Check each skill when you can explain it without looking at notes.

0 of 4 ready

Quick answers

Frequently asked questions

What is the difference between lossless and lossy compression?

Lossless compression preserves every bit of the original file after decompression. Lossy compression removes some information permanently to achieve much smaller sizes. You cannot recover discarded lossy detail by decompressing again. AP items test whether you know which situation tolerates that permanent loss.

Is JPEG lossy or lossless?

JPEG is lossy, designed for photographs where small color changes are hard to notice. It is a poor choice for text screenshots or UI assets with sharp edges because artifacts blur letters. PNG is usually better when exact pixels matter.

When should you choose PNG over JPEG?

Choose PNG when you need exact pixels: logos, diagrams, screenshots with text, or images that will be edited repeatedly. Choose JPEG when you are sharing photos where file size matters more than perfect pixels. State the user goal in your answer so the grader sees content-aware reasoning.

Is ZIP lossy or lossless?

ZIP is lossless for the files inside the archive. Extracting restores the same bytes you compressed, which is why software distributions and homework submissions use ZIP. Do not confuse ZIP with image codecs inside the archive—each inner file still has its own format.

Why is MP3 considered lossy?

MP3 removes sound details judged less audible to human ears. The result is far smaller than raw audio waveforms. Audiophiles may prefer lossless FLAC, but streaming platforms overwhelmingly use lossy codecs for bandwidth. Exam scenarios about music sharing usually accept that tradeoff.

What are compression artifacts?

Artifacts are visible or audible flaws from aggressive lossy settings—blocky JPEG regions, ringing around edges, or muddy music. They appear when compression is pushed too hard or a file is re-saved many times. Mentioning artifacts shows you understand that lossy is not free savings.

Can lossless compression still shrink every file?

No. Already compressed or encrypted files may not get smaller and can grow slightly due to headers. Lossless algorithms need patterns like repeated text or empty space. If a stem describes encrypted ciphertext, expect poor compression gains.

How do you justify a format choice in two sentences?

Sentence one: name the content (medical scan, pop song, contract PDF). Sentence two: tie tolerance for error to lossless or lossy and name a format. That structure mirrors how AP written prompts score clarity without needing brand slogans.

What lossless format fits legal document scans?

Lossless choices such as PNG or TIFF for images, or ZIP for bundles of PDFs, keep every pixel of a signature or stamp intact. Lossy scans could alter fine lines and create legal doubt. Exams use that context to push lossless answers.

Where do students confuse lossless and lossy most often?

They memorize format names without scenarios, pick JPEG for text screenshots, or assume bigger file size always means lossless quality. Practice eight MCQs here, then explain aloud why a yearbook photo and a geometry diagram need different formats. Speaking the reasoning cements the distinction better than flashcards alone.

Practice MCQs Unit 2 hub