Fill in the blanksQuestion 1 · Recall
Loading…
By the end you can encode and decode data with run-length encoding, work out the compressed size, and say when RLE helps and when it backfires.
Imagine reading AAAAAAAAAAAA aloud to a friend over the phone. By the fourth "A" you'd give up and say "twelve As".
Congratulations: you've just invented RLE.
Run-length encoding (RLE)
A lossless compression method in which each run (a sequence of consecutive, identical data items, such as characters or pixel colours) is replaced by one copy of the item and a count of how many times it repeats.
Worked example: Encode a very sleepy message
Encode ZZZZZZZZzzzzzz!!! with RLE as count–character pairs. Each count and each character takes 1 byte.
Worked example: Decode it back
Decode the RLE data 5A 1R 2G 1H.