Introduction
Imagine you have a big box full of clothes that you want to fit into a small suitcase for a trip. Data compression solves a similar problem by making large files smaller so they take up less space and travel faster over the internet.
Jump into concepts and practice - no test required
Think of packing a suitcase: rolling clothes tightly to save space is like lossless compression, where nothing is lost but space is saved. Throwing away some extra shoes or bulky items to fit the suitcase is like lossy compression, where some details are sacrificed for smaller size.
┌─────────────────────────────┐ │ Original Data │ │ (Large file with patterns) │ └─────────────┬───────────────┘ │ ┌───────▼────────┐ │ Compression │ │ (Find patterns, │ │ replace repeats)│ └───────┬────────┘ │ ┌─────────────▼───────────────┐ │ Compressed Data │ │ (Smaller file, less space) │ └─────────────┬───────────────┘ │ ┌───────▼────────┐ │ Decompression │ │ (Restore data) │ └───────┬────────┘ │ ┌─────────────▼───────────────┐ │ Original Data Restored │ │ (Exact or approximate copy)│ └─────────────────────────────┘
"AAAABBBCCDAA" is compressed by replacing repeated letters with the letter and count (e.g., A4 for AAAA). What is the compressed form?