当前位置:网站首页>哈夫曼树基本概念
哈夫曼树基本概念
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,则从根到每个叶子的路径上,分别构成一个二进制串,该二进制串称为哈夫曼编码。
进行哈夫曼编码,先建哈夫曼树。
哈夫曼编码是前缀编码,且是最优前缀编码。
边栏推荐
- 图形化工具打包YOLOv5,生成可执行文件EXE
- Not All Points Are Equal Learning Highly Efficient Point-based Detectors for 3D LiDAR Point
- Centerx: open centernet in the way of socialism with Chinese characteristics
- OC, OD, push-pull explanation of hardware
- 如何替换模型的骨干网络(backbone)
- What about SSL certificate errors? Solutions to common SSL certificate errors in browsers
- 制作(转换)ico图标
- 从 1.5 开始搭建一个微服务框架——日志追踪 traceId
- Lost in the lock world of MySQL
- Starting from 1.5, build a micro Service Framework -- log tracking traceid
猜你喜欢
How to replace the backbone of the model
20.(arcgis api for js篇)arcgis api for js面采集(SketchViewModel)
数学归纳与递归
Flutter3.0了,小程序不止于移动应用跨端运行
“去虚向实”大潮下,百度智能云向实而生
VHDL实现任意大小矩阵乘法运算
Development of wireless communication technology, cv5200 long-distance WiFi module, UAV WiFi image transmission application
Flink task exit process and failover mechanism
树莓派设置静态ip
2022.6.28
随机推荐
又一百万量子比特!以色列光量子初创公司完成1500万美元融资
[Dameng database] after backup and recovery, two SQL statements should be executed
Flink Task退出流程与Failover机制
What about SSL certificate errors? Solutions to common SSL certificate errors in browsers
Leetcode-02 (linked list question)
Optimization of application startup speed
[dream database] add the task of automatically collecting statistical information
CVPR 2022 best paper candidate | pip: six inertial sensors realize whole body dynamic capture and force estimation
Under the tide of "going from virtual to real", Baidu AI Cloud is born from real
Lavel PHP artisan automatically generates a complete set of model+migrate+controller commands
Jericho turns on the display icon of the classic Bluetooth hid mobile phone to set the keyboard [chapter]
Appx代码签名指南
Don't you know the relationship between JSP and servlet?
制作(转换)ico图标
Laravel php artisan 自动生成Model+Migrate+Controller 命令大全
Do you know the five most prominent advantages of E-bidding?
Another million qubits! Israel optical quantum start-up company completed $15million financing
Netperf and network performance measurement
25.(arcgis api for js篇)arcgis api for js线修改线编辑(SketchViewModel)
尚硅谷JVM-第一章 类加载子系统