Обновить u9/huffman_tree.py
This commit is contained in:
parent
40a8a27209
commit
c7d7dc0620
@ -28,13 +28,10 @@ class HuffmanTree:
|
|||||||
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:
|
||||||
second = first
|
second = first
|
||||||
first = i
|
first = i
|
||||||
elif nodes[i].frequency < nodes[second].frequency:
|
elif nodes[i].frequency < nodes[second].frequency:
|
||||||
second = i
|
second = i
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user