Data Compression
Compression stores the same information in fewer bits.
About this topic
Data compression makes files smaller so they use less storage and travel faster over networks. Lossless compression, used in ZIP and PNG, shrinks data and lets you recover the original exactly. Lossy compression, used in JPEG and MP3, discards information people are unlikely to notice for much greater savings.
Many methods work by finding repetition. Run-length encoding replaces repeated items with a count: AAAAABBB becomes 5A3B, saving space. Huffman coding gives shorter codes to common symbols, like Morse code giving E a single dot. Dictionary methods store repeated phrases once and refer back to them.
Compression ratio compares sizes: a 10 MB file reduced to 2 MB has a ratio of 5 to 1. Compressing a text document with lossless methods is safe, but repeatedly saving a JPEG loses quality each time. Streaming video would be impossible without compression, since raw high-definition video needs gigabits per second. A common misconception is that every file can be shrunk; already compressed or random data often cannot. Choose lossless for documents and code, and lossy when small size matters more than perfection.
Key ideas
- Lossless keeps everything
- Lossy drops detail
- ZIP vs JPEG
Quick check
Use cases: where Data Compression helps
- Homework: review the key idea behind Data Compression before you start a problem set.
- Exam revision: use the quick check to test whether you can recall Data Compression without notes.
- Visual learning: play with the interactive lab to see how Data Compression changes when you adjust its inputs.
- Teaching a friend: explain Data Compression in your own words, then compare your version with the key ideas.
Computing ideas run phones, search engines, games and the wider internet.
Frequently asked questions
What is Data Compression?
Compression stores the same information in fewer bits.
What will I learn in Data Compression?
Lossless keeps everything. Lossy drops detail. ZIP vs JPEG.
Is Data Compression part of Computer Science?
Yes. It is one of 80 Computer Science topics on LearnViz HighSchoolEdu, with 3 key ideas, a live animation and a quick check.
Does the Data Compression lab work on a phone or tablet?
Yes. The animation resizes to fit your screen and supports touch, so you can drag, tap and slide with your finger.
How should I study Data Compression?
Read the summary and key ideas first, play with the interactive lab to see the idea in motion, then answer the quick check. If you get a question wrong, go back to the key idea it tests.
Do I need an account, and is my progress saved?
No account is needed. Marking a topic as learned is saved in your own browser, so it stays on that device and is not sent to a server.