AP Computer Science Principles
Unit 2.2 – Data Compression and Storage

1. What Is Data Compression?

Data compression is the process of reducing the number of bits used to represent information. We compress data to:

Compression is essential because all digital data—text, audio, video, and images—takes up space, and smaller files move faster across the internet.

2. Types of Compression

There are two main types of compression: lossless and lossy.

2.1 Lossless Compression

Definition: Compression that reduces file size without losing any data. When decompressed, the file is restored perfectly.

Key Features:

Examples:

Common Techniques:

2.2 Lossy Compression

Definition: Compression that permanently removes some data to greatly reduce file size. Restored versions are not identical.

Key Features:

Examples:

Why Lossy Works Well:

3. When to Use Lossless vs. Lossy Compression

Situation Use Reason
Text files Lossless Every character must be preserved exactly
Medical/scientific images Lossless Accuracy and precision required
ZIP archives Lossless Must restore original files
Online photos Lossy Smaller size more important than perfect quality
Streaming video/music Lossy Faster transmission and lower bandwidth
Editing images/audio Lossless first, lossy at the end Preserves quality during editing

4. How Data Is Stored

All digital data—images, text, sound, video—is stored as binary (0s and 1s).

Storage Units:

Typical File Sizes:

5. How Data Is Transmitted

Data is transmitted across networks in small, manageable chunks called packets.

Each Packet Contains:

Key Principles:

6. Why Compression Helps Transmission

Compression reduces file size, which:

Example: A 10 MB photo compressed to 2 MB transfers five times faster.

7. Big Takeaways for AP CSP