Обновить u9/huffman_tree.py
This commit is contained in:
parent
c7d7dc0620
commit
dcb5665c0e
@ -27,6 +27,8 @@ class HuffmanTree:
|
|||||||
while len(nodes) > 1:
|
while len(nodes) > 1:
|
||||||
first = 0
|
first = 0
|
||||||
second = 1
|
second = 1
|
||||||
|
if nodes[first].frequency > nodes[second].frequency:
|
||||||
|
first, second = second, first
|
||||||
|
|
||||||
for i in range(2, len(nodes)):
|
for i in range(2, len(nodes)):
|
||||||
if nodes[i].frequency < nodes[first].frequency:
|
if nodes[i].frequency < nodes[first].frequency:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user