Text Compression

You Can Say That Again!

Many computer users are familiar with compressed formats such as zip, gzip, or gif images. These are based on a method called Ziv-Lempel coding, which turns out to be an interesting exercise in finding patterns in text.

Children’s rhymes and stories are good examples for text compression, because they often involve repeated words and sequences.

Activity description (PDF)

Translations and other versions

Compressing Bananas


  • An older version of this activity can be downloaded in PDF format here. The content is similar to the current version, but there’s some extra technical information.

Curriculum Links

Great Principles of Computer Science [info]
  • Recollection, Communication
ACM K12 Curriculum [info]
  • Level I (Grades 3-–5) Topic 11: develop a simple understanding of an algorithm
New Zealand Curriculum [info]
    • Technology Level 1: Technological systems
      • Understand that technological systems have inputs, controlled transformations, and outputs.
  • Technology Level 3: Technological systems
    • Understand that technological systems are represented by symbolic language tools and understand the role played by the “black box” in technological systems.