HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Is Huffman Encoding always optimal?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
alwayshuffmanoptimalencoding

Problem

The requirement of the encoding to be prefix free results in large trees due to the tree having to be complete. Is there a threshold where fixed-length non-encoded storage of data would be more efficient than encoding the data?

Solution

Huffman coding approximates the population distribution with powers of two probability. If the true distribution does consist of powers of two probability (and the input symbols are completely uncorrelated), Huffman coding is optimal. If not, you can do better with range encoding. It is however optimal among all encoding that assign specific sets of bits to specific symbols in the input.

Context

StackExchange Computer Science Q#3176, answer score: 9

Revisions (0)

No revisions yet.