码迷,mamicode.com
首页 > 其他好文 > 详细

Huffman codes

时间:2015-04-18 21:58:54      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

   

Huffman codes  compress data very effectively: savings of 20% to 90% are typical, depending on the characteristics of the data being compressed. 

  功能:

  huffman 编码能有效的压缩数据。

  如何解决:

  Huffman’s greedy algorithm uses a table giving how often each character occurs (i.e., its frequency) to build up an optimal way of representing each character as a binary string. 

  

  we interpret the  binary codeword for a character as the simple path from the root to that character ,where 0 means go to the left child and 1 means  go to the right child .

  

we interpret the  binary codeword

for a character as the simple path from the root to that character ,where 0 means go to the left child and 1 means  go to the right child .

 

Note that these are not binary search trees, since the leaves need not appear in sorted order and internal nodes do not contain character keys.

an optimal code for a  file is always represented by a fully binary tree ,in which every nonleaf has two children .

 

the tree for an optimal prefix code has exactly |C| leaves ,one for each letter of the alphabet ,ash exactly |c|-1interanl nodes .

 

 

 

 

what is the meaning 

when we merge two objects ,the result is a new object whose frequency is the sum of the frequencies of the two object that were merged . 

 

   

Huffman codes

标签:

原文地址:http://www.cnblogs.com/ljlkfx/p/4438089.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!