Example

Huffman Coding example of “mississippi river”

Algorithm:

 -combine last 2 nodes of linked list to create a binary tree. 
 -root node string is concatenation of last node + second last node strings
 -root node sum is sum of last node + second last node integers
 -insert root node of new binary tree into linked list 
(insertion is sorted by integer then sub sorted by string if integers are equal)
 -repeat until only 1 node left in linked list.

huffman.png