早教吧作业答案频道 -->数学-->
给定权值(7,18,3,32,5,26,12,8),构造相应的哈夫曼树如题,麻烦写出过程,谢谢!原题我看过,不过不够细,可否细一些
题目详情
给定权值(7,18,3,32,5,26,12,8),构造相应的哈夫曼树
如题,麻烦写出过程,谢谢!
原题我看过,不过不够细,可否细一些
如题,麻烦写出过程,谢谢!
原题我看过,不过不够细,可否细一些
▼优质解答
答案和解析
这还不够细?
3+5=8,此时序列为8 7 8 12 18 26 32
7+8=15,此时序列为15 8 12 18 26 32
8+12=20,此时序列为15 20 18 26 32
……每一步都挑最小的两个相加.
图见下面.
多看书,baidu上不好画图,打这些东西很累.
------------------
原答题者:plause
按权值大小排列后 3 5 7 8 12 18 26 32
只要按照将最小的两个合并, 合并后的值再入列中(最小的两个出列), 至到列中只有一个值.
按上面要求构造哈夫曼树如下:
/////树列完后, 可取左树编码 为0, 右为 1, (左为 1, 右为 0 亦可)
[3]`````[5]`````````[7]``````[8]
``\`````/`````````````\``````/
`0`\```/`1```````````0`\````/`1
````\`/`````````````````\``/
````(8)`````[12]````````(15)`````[18]
``````\``````/`````````````\``````/
`````0`\````/`1```````````0`\````/`1
````````\``/`````````````````\``/
````````(20)``````[26]```````(33)``````[32]
```````````\``````/`````````````\``````/
``````````0`\````/`1```````````0`\````/`1
`````````````\``/`````````````````\``/
`````````````(46)`````````````````(65)
````````````````\`````````````````/
```````````````0`\```````````````/`1
``````````````````\`````````````/
```````````````````````(111)
则按上面的树可得到各权值所对应的编码:
//// 其编码是从树顶到该权值点所经过的 1 或 0 的序列
[`7]:``1`0`0`0
[18]:``1`0`1
[`3]:``0`0`0`0
[32]:``1`1
[`5]:``0`0`0`1
[26]:``0`1
[12]:``0`0`1
[`8]:``1`0`0`1
3+5=8,此时序列为8 7 8 12 18 26 32
7+8=15,此时序列为15 8 12 18 26 32
8+12=20,此时序列为15 20 18 26 32
……每一步都挑最小的两个相加.
图见下面.
多看书,baidu上不好画图,打这些东西很累.
------------------
原答题者:plause
按权值大小排列后 3 5 7 8 12 18 26 32
只要按照将最小的两个合并, 合并后的值再入列中(最小的两个出列), 至到列中只有一个值.
按上面要求构造哈夫曼树如下:
/////树列完后, 可取左树编码 为0, 右为 1, (左为 1, 右为 0 亦可)
[3]`````[5]`````````[7]``````[8]
``\`````/`````````````\``````/
`0`\```/`1```````````0`\````/`1
````\`/`````````````````\``/
````(8)`````[12]````````(15)`````[18]
``````\``````/`````````````\``````/
`````0`\````/`1```````````0`\````/`1
````````\``/`````````````````\``/
````````(20)``````[26]```````(33)``````[32]
```````````\``````/`````````````\``````/
``````````0`\````/`1```````````0`\````/`1
`````````````\``/`````````````````\``/
`````````````(46)`````````````````(65)
````````````````\`````````````````/
```````````````0`\```````````````/`1
``````````````````\`````````````/
```````````````````````(111)
则按上面的树可得到各权值所对应的编码:
//// 其编码是从树顶到该权值点所经过的 1 或 0 的序列
[`7]:``1`0`0`0
[18]:``1`0`1
[`3]:``0`0`0`0
[32]:``1`1
[`5]:``0`0`0`1
[26]:``0`1
[12]:``0`0`1
[`8]:``1`0`0`1
看了 给定权值(7,18,3,32...的网友还看了以下:
盒中原有7个小球,魔术师从中取出若干个球,把每个球都变成7个小球,将其放回盒中;他又由其中取出若干个 2020-03-30 …
英语翻译主啊,我们向你祈祷,希望我们能永远继续彼此付出,能够继续彼此原谅,并且每天都能经历越来越多 2020-05-16 …
计算(-1/24)/(2/3-3/4+7/8)利用倒数的意义,先求出原式的倒数,再得原式的值.这个 2020-05-17 …
甲、乙两名同学解方程组mx+y=5①2x-ny=13②,甲解题时看错了中的m,解的结果是x=7/2 2020-06-26 …
一个方155元,正方形30CM×30CM等于多少元?不够0.1.按0.1算.要怎样才算的出来够不够 2020-07-18 …
分数乘负数怎么算啊1/6剩(-7)怎么算,说出原因原题是负1减1/6乘(负7)等于1+7/6等于1 2020-07-30 …
修改病句小而言之,读书不但可以提升自我,而且能够增长知识不是乱答的采纳,并且说出原因,乱答的别修改病 2020-11-03 …
求解,急用点心店里卖大小两种蛋糕,一个人恰好够7人吃,一个小蛋糕恰好够4个,现在有100个人要吃蛋糕 2020-11-16 …
英语翻译1.犯错误2.改正3.通读整篇写作4.如何解决压力问题5.给予改正6.受苦7.吃健康的饮食, 2020-11-22 …
学生小强所在学校将学生到校时间推迟半小时,小强原来7点从家出发乘坐公交车,7点20分到校,现在小强若 2020-12-28 …