Day 6 - Lossless Data Compression

Day 6: Lossless Data Compression

Learning Objectives

Essential Questions

Materials Needed

Vocabulary

Procedure (50 minutes)

Opening (8 minutes)

  1. Review and Connection (3 minutes)

    • Review file formats from previous lesson
    • Connect to today's focus on reducing file sizes through compression
  2. Warm-up Activity (5 minutes)

    • Display a repetitive pattern (e.g., "AAABBBCCCAAABBBCCC")
    • Ask students: "How could we write this more efficiently?"
    • Collect student ideas on the board

Main Activities (32 minutes)

  1. Lecture: Principles of Lossless Compression (12 minutes)

    • Define lossless compression: reducing file size while preserving all original information
    • Explain that lossless compression works by eliminating redundancy
    • Discuss key properties:
      • Original data can be perfectly reconstructed
      • Effectiveness depends on data redundancy
      • Some data compresses better than others
    • Introduce compression ratio as a measure of effectiveness
    • Explain when lossless compression is most appropriate (text, spreadsheets, program files, etc.)
  2. Demo: Run-length Encoding and Dictionary-based Compression (10 minutes)

    • Explain run-length encoding (RLE):
      • Replace sequences of repeated data with a count and the data item
      • Example: "AAABBBCCC" → "3A3B3C"
      • Show examples with text and simple images
    • Introduce dictionary-based compression:
      • Replace common patterns with shorter references
      • Example: "the the the" → Dictionary: {1:"the"} → "1 1 1"
      • Briefly explain how LZW and other algorithms work
    • Demonstrate compression and decompression with examples
  3. Activity: Manually Compress and Decompress Data (10 minutes)

    • Provide students with sample data (text strings, simple bitmap patterns)
    • Students work in pairs to:
      • Apply run-length encoding to compress the data
      • Exchange their compressed data with another pair
      • Decompress their peers' data to recover the original
      • Calculate the compression ratio achieved
    • Discuss which samples compressed well and which didn't

Closing (10 minutes)

  1. Discussion and Analysis (5 minutes)

    • What types of data are most suitable for RLE? Why?
    • What are the limitations of the compression techniques we explored?
    • How might compression algorithms be optimized for different types of data?
    • Real-world applications of lossless compression
  2. Worksheet and Preview (5 minutes)

    • Students complete a worksheet on lossless compression techniques
    • Preview that next class will focus on lossy compression techniques

Assessment

Differentiation

For Advanced Students

For Struggling Students

Homework/Extension

Teacher Notes