按權值大小排列後357812182632 只要按照將最小的兩個合併,合併後的值再入列中(最小的兩個出列),至到列中只有一個值. 按上面要求構造哈夫曼樹如下: /////樹列完後,可取左樹編碼為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
按權值大小排列後357812182632 只要按照將最小的兩個合併,合併後的值再入列中(最小的兩個出列),至到列中只有一個值. 按上面要求構造哈夫曼樹如下: /////樹列完後,可取左樹編碼為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