Compression - Huffman Coding and RLE

Students following some courses, such as AQA GCSE Computer Science, are required to know how compression techniques such as Huffman Coding and Run-Length Encoding work. This interactive page allows you to enter some text in the box below and see how the number of bits used to represent it can be reduced using those techniques.

Run-Length Encoding

There is no text to compress.

Huffman Coding

Character Frequencies

There is no text to compress.

Tree

The frequency information above can be used to create a binary tree (you can zoom in if you are using a mobile device):

Codes

The tree can be used to assign a code to each character. Starting at the root, follow the branches down to the character, adding a 0 each time you take a left (red) branch and a 1 each time you take a right (green) branch. If you compare the codes with the frequency of the characters, you should see that the most common characters have the shortest codes.

Details will appear here when more text is entered.

Comparison

Details will appear here when more text is entered.