Compression encodes data into a smaller representation, while decompression reverses that encoding and restores the original data. It trades processing time for reduced storage or transmission space. section 1.2
A practical compression decision follows three observations:
- Choose compression when smaller storage or transmission size matters more than immediate execution speed. section 1.2
- Use a narrower storage type when the possible values already fit within fewer bits; a UInt16 can replace an oversized UInt for values up to 65,535. section 1.2
- Recognize simple bit-string compression as a special case; broader algorithms usually remove repeated information by finding patterns or structure. section 1.6
Encoding a gene
A gene containing only A, C, G, and T needs two bits per nucleotide: 00, 01, 10, and 11. Store those pairs in a bit vector, retain the original length, and decode each pair to reconstruct the gene. section 1.2
Use the figure to trace how nucleotide characters become a compact two-bit string. section 1.2










