Daily whim 001-- Huffman (Huffman / Huffman) encoding

Today in class data structure lesson content

Huffman coding

Initially intended to calculate the optimal length of the encoded found 26 letters are a number of occurrences of the time, as long as coding will account for enormous advantage, and Huffman coding had to run twice text, and other than slow-length coding a lot of.

Length coding such as Huffman coding and are not anti-jamming capability, this comparison is not here.

Huffman coding whim want to test the energy ratio of length coding advantage under what circumstances this time thought Kenji Wu songs (really exposed Age)

Although the lyrics are really straightforward, I do not like it, but this degree of repetition, I can imagine reflect the advantages of Huffman coding, right?

however…

(Here is a word count)

Said 15

You 3

Love 3

I 12

No 3

Out 2

Port 10

Sound 4

Of 2

Of 1

From 1

1

Big 2

Tongue 2

Head 2

On 1

Huffman coding: 15 * 1 + 12 * 2 + 10 * 3 + 4 * 4 + 3 * 5 + 3 * 6 + 3 * 7 + 2 * 8 + 2 * 9 + 2 * 10 + 2 * 11 + 2 * 12 + 13 + 14 + 15 + 15 = 296 (296 01 code means that the lyrics)

Isometric Code:

5 * 7 * 8 = 280 (16 characters represented by binary number five, seven words a total of eight lyrics)

 

...... This time I lost in thought, word evidently is estimated to be too low frequency of appearance, the first three sentences considered good ( '· ω ·) "

 

(Statistics again)

Said 7

You1

Love 1

I 5

Not 1

Out 1

Port 5

Sound 2

5

Huffman coding:

7*1+5*2+5*3+2*4+5+6+7+8+8=74

Isometric Code:

7 * 4 * 3 = 84 (not explained supra)

 

Finally ...... men and women silent tears ( '-ι_- `)

This is not only slow Ah requires quite high, I think is really quite weak chicken ...

Only personal point of view wailing, have time to want to try to calculate how many duplicate proportion, accounting for the number of low-frequency character encoding Huffman coding, etc. can be longer than the short, ah me nothing good.

Guess you like

Origin www.cnblogs.com/jun-ruo-sui-nian/p/qsmx_001.html