Afterglowscreensavers

Huffman Coding Tree Builder Screensaver

The Huffman Coding Tree Builder screensaver builds a real live Huffman tree from genuine letter frequencies, merging the two least-frequent nodes at each step into optimal codes. It is free, runs in your browser, and ESC exits.

Live preview

Press ESC to leave fullscreen. Settings are saved in your browser only.

How the Huffman Coding Tree Builder screensaver works

The saver counts the real letter frequencies of a random block of text, then creates one leaf node per distinct letter.

At each step, the real two least-frequent nodes are merged into a new parent node whose frequency is their sum, exactly the greedy rule Huffman coding uses.

This repeats until a single root node remains, and each leaf's real code is read off as the path of left/right branches down from the root.

Once the tree completes, the real resulting codes are shown briefly next to each letter, then a fresh random text and tree build begins.

A worked example

The most frequent letter in the text ends up with the real shortest code — often just one or two bits — while a rare letter gets a real longer code, exactly the compression trade-off Huffman coding guarantees is optimal.

Settings & tips

Frequently asked questions

Is this a real compression algorithm?
Yes — real Huffman coding, still used today inside formats like ZIP, JPEG and MP3.
Why do common letters get shorter codes?
It is a real, provably optimal trade-off — assigning shorter codes to frequent symbols minimizes the total encoded length.
Is a key needed?
No — it is a pure local computation.
Is it free?
Yes — free, no download, in your browser.

← All Science & Research screensavers