Data representation · GCSE · OCR J277 1.2.5, AQA 8525 3.3.8, Edexcel 1CP2 2.3.2 · about 20 min
Lossy and lossless; run length encoding and Huffman coding.
[1 mark]Which kind of compression must be used for a program file?
[1 mark]What does lossy compression do?
[1 mark]Run length encode WWWWBBW in the form count then character.
[1 mark]On which data does RLE work worst?
[1 mark]In Huffman coding, which characters get the shortest codes?
Write rle_encode(text) and rle_decode(code) yourself. Encode the row ........######....######........ and print it as encoded: <code>, then print original: <n> characters, encoded: <m> characters, and finally decoded matches: True, using your decode function.
# the two lines every program starts with: the commands, then the robot from bugbot import * connect() row = "........######....######........"
Plan your program here, then type it in and press Run.
codes round into a dictionary from code to character, and read bits until they match a code.