当前位置:网站首页>哈夫曼树基本概念
哈夫曼树基本概念
2022-07-06 20:18:00 【木子正文_啊嘞】
哈夫曼树的基本概念:
(1)路径:由一结点到另一结点间的分支所构成
(2)路径长度:路径上的分支数目a→d的路径长度= 2
(3)树的路径长度:从树根到每一结点的路径长度之和。 例图:10
(4)权:赋予某个实体的一个量,是对实体的属性的数值化描述。若树的结点带有权值,即为带权树。
(5)结点的带权路径长度:结点到根的路径长度与结点上权值的乘积d的带权路径长度=72=14
(6)树的带权路径长度:树中所有叶子结点的带权路径长度之和。例图:27+25+22+2*4=36
(7)赫夫曼树(Huffman):最优二叉树,带权路径长度最小的树
哈夫曼树的特点
- 权值大的结点到根结点的路径长度短;
- 权值小的结点到根结点的路径长度长。
Ø哈夫曼编码树中没有度为1的结点;
Ø若给定n个权值(n个叶子结点),则哈夫曼树的总结点数为 2n-1;
Ø哈夫曼树的高度不超过n。
哈夫曼树的构造算法:
哈夫曼编码:
v前缀编码:任一字符的编码都不是另一字符编码的前缀。
如:字符a、b、c、d的编码分别为0、1、01、10,则a的编码是c的编码的前缀,b的编码是d编码的前缀,该编码不是前缀编码。
在译码时,对于01011011的译码结果将不唯一。
v哈夫曼编码
对一棵具有n个叶子的哈夫曼树,对每个左分支赋予0,右分支赋予1,则从根到每个叶子的路径上,分别构成一个二进制串,该二进制串称为哈夫曼编码。
进行哈夫曼编码,先建哈夫曼树。
哈夫曼编码是前缀编码,且是最优前缀编码。
边栏推荐
- Variables, process control and cursors (MySQL)
- 注意力机制原理
- VHDL实现任意大小矩阵乘法运算
- Leetcode-02 (linked list question)
- 21.(arcgis api for js篇)arcgis api for js矩形采集(SketchViewModel)
- Shell 编程基础
- 源代码保密的意义和措施
- When you go to the toilet, you can clearly explain the three Scheduling Strategies of scheduled tasks
- Numpy中排序操作partition,argpartition,sort,argsort
- 函数重入、函数重载、函数重写自己理解
猜你喜欢
Flink Task退出流程与Failover机制
树莓派设置wifi自动连接
存储过程与函数(MySQL)
Intelligent static presence detection scheme, 5.8G radar sensing technology, human presence inductive radar application
How-PIL-to-Tensor
Hazel engine learning (V)
“去虚向实”大潮下,百度智能云向实而生
Variables, process control and cursors (MySQL)
CVPR 2022 最佳论文候选 | PIP: 6个惯性传感器实现全身动捕和受力估计
首届“量子计算+金融科技应用”研讨会在京成功举办
随机推荐
Experience design details
When you go to the toilet, you can clearly explain the three Scheduling Strategies of scheduled tasks
腾讯云原生数据库TDSQL-C入选信通院《云原生产品目录》
Jerry's transmitter crashed after the receiver shut down [chapter]
Lab1 configuration script
首届“量子计算+金融科技应用”研讨会在京成功举办
Room rate system - login optimization
安装 torch 0.4.1
24.(arcgis api for js篇)arcgis api for js点修改点编辑(SketchViewModel)
21.(arcgis api for js篇)arcgis api for js矩形采集(SketchViewModel)
Nuggets quantification: obtain data through the history method, and use the same proportional compound weight factor as Sina Finance and snowball. Different from flush
应用程序启动速度的优化
【安全的办公和生产力应用程序】上海道宁为您提供ONLYOFFICE下载、试用、教程
Do you know the five most prominent advantages of E-bidding?
Household appliance industry under the "retail is king": what is the industry consensus?
Matlab Error (Matrix dimensions must agree)
Optimization of application startup speed
How-PIL-to-Tensor
cocos3——8.实现初学者指南
25.(arcgis api for js篇)arcgis api for js线修改线编辑(SketchViewModel)