Lecture 5/29: Huffman Coding


May 29, 2020

đź“‚Associated files

Huffman Coding

CS 106B: Programming Abstractions

Spring 2020, Stanford University Computer Science Department

Lecturers: Chris Gregg and Julie Zelenski

A diagram showing a huffman-coded tree. Each non-leaf node in the tree has an integer value, and the leaves all hold a letter/frequency combination. The value of a node is the sum of all the frequencies below that node


Slide 2

Announcements


Slide 3

Today's Topics

Note: many of the ideas in this lecture were developed by Eric Roberts, Professor emeritus at Stanford, now at Reed College.


Slide 4

Motivation


Slide 5

All characters are just numbers


Slide 6

Can we do better than 8 bits per letter?


Slide 7

Early Prefix-Coding Strategies


Slide 8

The Shannon-Fano Algorithm


Slide 9

Illustrating the Shannon-Fano Algorithm


Slide 10

The Huffman Algorithm


Slide 11

Illustrating Huffman Coding


Slide 12

The Huffman Tree for Scrabble Tiles