Skip to content

Implementing HuffmanTree to encode or decode a string with c++

Notifications You must be signed in to change notification settings

zhoujiajun/HuffmanTree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

用c++实现赫夫曼树——给字符串编码与解码

原理:根据英文26个字母的出现频率,构造一棵赫夫曼树,频率越高的字母(如e),越靠近赫夫曼树的根。 每个字母的编码,正是从根节点开始,到追溯到该字母为止,遍历左子树设为0,遍历右子数设为1。 此时,每个字母便有固定编码,直接利用该编码完成对字符串的编码与解码。 按照最优思想,此时字母编码的平均长度最短。(因为频率最高的最靠近根节点,编码后的长度自然最小)

About

Implementing HuffmanTree to encode or decode a string with c++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages