ZIP is a file format that bundles several files into one and shrinks them with a method that brings them back exactly as they were (lossless compression, 可逆圧縮).
Restoring compressed data to its original form is called decompression (伸長, also 展開). When you decompress a ZIP file, the files you bundled come back without losing a single bit. It works with any kind of content, from documents to programs, so people use it to send or store many files at once.
AnalogyIt is like packing a stack of papers into one envelope so it ships flat. Open the envelope and every sheet is still there.
How to rememberIn English, "zip" means to close a zipper. Picture gathering loose things into a bag and zipping it shut.
Exam points
Mix-upZIP is a general-purpose lossless compression (可逆圧縮) format that accepts any content, which sets it apart from formats built for one kind of data, such as JPEG for photos.
The compression ratio (圧縮率) is a value that shows how well compression works, found by dividing the data size after compression by the size before.
Before
After
Compression ratio
800 KB
200 KB
200 ÷ 800 = 25%
800 KB
600 KB
600 ÷ 800 = 75%
The value is written as a ratio or a percentage, and the smaller it is, the more the data has shrunk. Count the data size in the same unit before and after compression, whether that unit is bits, bytes, or characters.
AnalogyIf a duvet in a vacuum storage bag shrinks to one third of its original thickness, that one third is the compression ratio.
How to rememberRead it as the share of what is left. The less that remains, the better the compression worked.
Exam points
ExamTo find the compression ratio (圧縮率), count the compressed size by the agreed rules for writing the data, then divide it by the original size.
Mix-upThe term "compression ratio" (圧縮率) is sometimes used for the share that was removed (1 − compressed ÷ original). Check the definition the document gives to see which meaning it uses.
Lossless compression (可逆圧縮) is a compression method in which decompression brings back the original data exactly.
← Scroll the figure sideways →
It throws away no information and only shortens the way the data is written, so it is used for documents and programs where changing even one character would cause problems. Because nothing is discarded, though, there is a limit to how much it can shrink. Among image formats, PNG and GIF also use lossless compression.
AnalogyIt is like a folding umbrella: it packs down small, yet opens back into exactly the same shape.
How to rememberThe Japanese name 可逆 means "reversible": the process can run back to where it started. The English word "lossless" makes the same point, since nothing is lost.
Exam points
Mix-upWhether a method counts as lossless compression (可逆圧縮) depends on whether the data can be restored, not on the kind of data, and image formats include lossless ones such as PNG.
Lossy compression (非可逆圧縮) is a compression method that removes information people barely notice to cut the data size sharply, so decompression cannot fully restore the original.
Original data
Remove fine details that are hard to notice
Much smaller data
Slightly different from the original after decompression
Decompression cannot bring back what was discarded, so the result differs slightly from the original.
4 / 4
The removed information never comes back, but that is exactly what allows such large reductions. It suits photos, audio, and video, where a slight loss of quality is hard to spot, and typical formats are JPEG for photos, MP3 for audio, and MPEG for video.
AnalogyIt is like retelling a long story in a few lines. The main points get across, but the listener cannot recover the original wording.
How to rememberSpilled water cannot be gathered back into the bucket, and the details you cut cannot be put back either.
Exam points
ExamMP3 is a compression format for audio that uses lossy compression (非可逆圧縮), removing components the ear has trouble hearing.
ExamMPEG is a family of standards for compressing video and audio data, and it uses lossy compression (非可逆圧縮) to cut the data size sharply.
Run-length encoding (ランレングス法) is a lossless compression technique that shortens data by replacing each stretch of a repeated value with the value and the number of times it repeats.
PPPPPPQQQR (10 characters)
P: 6, Q: 3, R: 1
P6Q3R1 (6 characters)
Writing each value with its count shrinks 10 characters to 6.
3 / 3
A stretch of the same value is called a run (ラン), and its length is the run length (ランレングス). Data with long runs, such as an image with wide areas of one color, compresses well, while a sequence whose value changes at every position barely shrinks and can even get longer. Details such as whether a value that appears only once also gets a count are set by each scheme.
AnalogyIt is like writing "6 oranges" on a shopping list instead of "orange, orange, orange…"
How to rememberRun (an unbroken stretch) plus length gives "the length of a run." The name itself tells you what gets recorded.
Exam points
ExamEven for the same image, changing the direction in which pixels are read changes where the runs break, and the compressed size can change with it.
ExamWhen a scheme writes each count in a fixed number of bits, a run longer than the largest value those bits can hold is split into several pieces and recorded separately.
Huffman coding (ハフマン法) is a lossless compression technique that reduces the total data size by giving shorter codes to values that appear more often and longer codes to values that appear less often.
Character
Share of occurrences
Assigned code
A
50%
0 (1 bit)
B
25%
10 (2 bits)
C
15%
110 (3 bits)
D
10%
111 (3 bits)
A code (符号) is the sequence of 0s and 1s assigned to represent a value. Compared with a scheme that gives every value a code of the same length, the total gets shorter the more uneven the frequencies are. In the example in the figure, each character takes 1.75 bits on average, fewer than the 2 bits needed when every character gets a code of the same length.
AnalogyIt is like putting the people you call most often on the shortest speed-dial numbers.
How to rememberIn Morse code, E, the most common letter in English, is a single dot. It is the same idea: the more often something appears, the shorter its code.
Exam points
Mix-upRun-length encoding (ランレングス法) looks at runs of the same value and sums them up as counts, while Huffman coding (ハフマン法) looks at how often each value appears and varies the length of the codes.
Run-length encoding vs. Huffman coding
Aspect
Run-length encoding
Huffman coding
Key differenceWhat it looks at
Runs of the same value
How often each value appears
How it rewrites data
Value and run count
Codes whose length depends on frequency
Data that compresses well
Long runs of the same value
Highly uneven frequencies
Key points
Restoring compressed data to its original form is called decompression, and a method that restores the data exactly is called lossless compression.
The compression ratio is the compressed size divided by the original size, and a smaller value means the data shrank more.
Photos, audio, and video mostly use lossy compression formats, such as MP3 for audio and MPEG for video.
Run-length encoding is a lossless compression technique that replaces a run of the same value with a pair made of the value and its count.
Huffman coding gives short codes to values that appear often, and it compresses better the more uneven the frequencies are.