How can a text file take less space without losing its letters? A file containing “tilt” takes 4 bytes when each character uses one byte. Huffman encoding uses a binary tree to give symbols variable-length codes: frequent symbols get shorter codes. It is a technique for lossless text compression. section 7.6 section 7.0
Try shorter codes for “tilt”
With two-bit codes—t = 00, i = 01, l = 10—“tilt” needs 8 bits. Give the repeated t a shorter code instead—t = 1, i = 00, l = 01—and the same letters need 6 bits: 1 00 01 1. That compares code lengths, not the size of a finished compressed file. section 7.6
Short codes must still be readable without confusion. For example, a = 0, b = 1, c = 00 is ambiguous: 00 could mean “aa” or “c.” A binary tree provides a way to organize codes so a sequence can be decoded. The focus here is how the tree is used, rather than the steps for constructing a Huffman tree. section 7.6



