首页>苗木百科>给定权值(5,10,12,15,30,40),构造相应的哈夫曼树.要求写出构造步骤

给定权值(5,10,12,15,30,40),构造相应的哈夫曼树.要求写出构造步骤

来源:www.lps114.com.cn   时间:2022-01-20 15:17   点击:6114   编辑:niming   手机版

按权值大小排列后 5,10,12,15,30,40
只要按照将最小的两个合并, 合并后的值再入列中(最小的两个出列), 至到列中只有一个值.
得到序列5+10=15, (12,15,15,30,40)
[5]`````[10]
\`````/
\```/`
\`/
` `(15)`
从(12,15,15,30,40)找两个最小的12+15=27
[5]`````[10]````````[12]``````[15]
``\`````/`````````````\``````/
` `\```/` ``````````` `\````/`
````\`/`````````````````\``/
````(15)````` ````````(27)`
依次从新的序列中取2个想加和最小的。
(15,27,30,40)-----取15+27=42;
(30,40,42)---------取30+40=70;
(42,70)-------------取42+70=112;
(112)就剩一个终止。

[5]`````[10]`[12]``````[15]
``\`````/``````\``````/
`0`\```/`1`````0\````/`1
````\`/``````````\``/
````(15)````` (27)``[30]`````[40]
``````\`````` /`````````\``````/
`````0`\```` /`1````````0\````/`1
````````\`` /`````````````\``/
```````` (42)````````````` (70)``````
```````````\`````` ````````````/
``````````0`\``````` ```````/
`````````````\ ```````````/
`````````````(46)``````````1/`
````````````````\``````````/``
```````````````0`\````````/``
``````````````````\``````/``
````````````````````(112)

图真不好画,详细可以参考

感觉不错,赞哦! (0)
下次努力,加油! (0)
网友评论仅供其表达个人看法,并不表明本站立场。
评论
    共 0 条评论
本站所发布的全部内容源于互联网搬运,仅限于小范围内传播学习和文献参考,请在下载后24小时内删除!
如果有侵权之处请第—时间联系我们删除。敬请谅解!qq:2850716282@qq.com
山茶油 滇ICP备2021006107号-532
关于本站 联系我们 特别鸣谢