Обновить u9/huffman_tree.py

This commit is contained in:
Arina Dohadailo 2026-11-12 22:51:16 +00:00
parent caba5f1d5a
commit 119664fb08

View File

@ -24,11 +24,11 @@ class HuffmanTree:
if not found:
nodes.append(HuffmanNode(char,1))
while len(nodes) > 1:
first = 0
second = 1
if nodes[first].frequency > nodes[second].frequency:
first, second = second, first
while len(nodes) > 1:
first = 0
second = 1
if nodes[first].frequency > nodes[second].frequency:
first, second = second, first
for i in range(2, len(nodes)):
if nodes[i].frequency < nodes[first].frequency: