From dcb5665c0e55a883f10964f16cb79cc988761bd4 Mon Sep 17 00:00:00 2001 From: Arina Dohadailo Date: Thu, 12 Nov 2026 22:43:44 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20u9/huffman=5Ftree.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- u9/huffman_tree.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/u9/huffman_tree.py b/u9/huffman_tree.py index b82dbdf..0029b8b 100644 --- a/u9/huffman_tree.py +++ b/u9/huffman_tree.py @@ -27,6 +27,8 @@ class HuffmanTree: 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: