Data Compression
| English | Chinese | Pinyin |
|---|---|---|
| Compression | 压缩 | yā suō |
| Internet | 互联网 | hù lián wǎng |
| Lossless | 无损 | wú sǔn |
| Lossy | 有损 | yǒu sǔn |
| size | 大小 | dà xiǎo |
| quality | 质量 | zhì liàng |
| trade-off | 权衡 | quán héng |
| redundancy | 冗余 | rǒng yú |
| transmission | 传输 | chuán shū |
Storing the same data in fewer bits
- A photo or song can hold millions of bytes — files get large.
- Compression 压缩 is any method that stores the same data using fewer bits.
- Smaller files take less space to store.
- And they are faster to send across the Internet 互联网.
Compression means storing the same data using:
Fewer bits means smaller files that store and send faster.
Match each method to its property.
Text needs lossless; photos and music often use lossy.
Which data type must use lossless compression?
One changed byte could break a program, so it must be lossless.
Lossless vs lossy
- Lossless 无损 compression keeps every bit — the data restores exactly.
- Text and program files must be lossless; one changed letter could break them.
- Lossy 有损 compression makes files much smaller by throwing away data people are unlikely to notice.
- The original cannot be restored exactly — photos, music, and video often use it.
Lossy compression trades data quality for smaller file size.
Smaller size usually means losing some detail.
The size–quality trade-off
- Lossy compression forces a trade-off 权衡 between two things.
- File size 大小: how many bits it needs. Data quality 质量: how close it is to the original.
- Squeezing smaller usually means losing more detail.
Same photo, two ways. A lossless file is 5 MB and looks perfect; a lossy file is 0.5 MB — ten times smaller — but slightly blurry when zoomed. For a fast website, pick the small lossy file; for a large sharp poster, pick the lossless one.
Run-length encoding (a lossless method)
Run-length encoding replaces a run of repeated values with one value plus a count. It is lossless — the original rebuilds exactly — but only shrinks data that has long runs.
Storing "100 white pixels" as "white, 100 times" works by removing:
Run-length encoding replaces a run with a value plus a count — lossless.
A compressed file with fewer bits transmits across a network faster.
Fewer bits to send means faster transmission.
Removing redundancy
- Many methods work by removing redundancy 冗余 — data that repeats or can be predicted.
- A line of 100 identical white pixels can be stored as "white, 100 times" instead of listing all 100.
- That is far fewer bits for the same picture — a lossless method called run-length encoding.
- Fewer bits also means faster transmission 传输 across a network.
Compression stores data in fewer bits — saving space and speeding transmission. Lossless keeps every bit (needed for text and code); lossy discards unnoticeable data for much smaller files (photos, music). Lossy forces a size–quality trade-off, and many methods shrink files by removing redundancy.