Build an optimal prefix code by merging the two lightest trees in a priority queue, then encode a text and decode bits by walking the tree.
This interactive visualization needs JavaScript.