From 758948d3bc7cb9f1eefe72629ab4aea002532d71 Mon Sep 17 00:00:00 2001 From: Arina Dohadailo Date: Thu, 12 Nov 2026 22:36:22 +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 | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/u9/huffman_tree.py b/u9/huffman_tree.py index 9b92ca4..efdaba0 100644 --- a/u9/huffman_tree.py +++ b/u9/huffman_tree.py @@ -10,7 +10,7 @@ class HuffmanNode: class HuffmanTree: def __init__(self, data): - self.root="" + self.root = None if data == "": return nodes = [] @@ -24,27 +24,30 @@ class HuffmanTree: if not found: nodes.append(HuffmanNode(char,1)) - while len(nodes)>1: + while len(nodes) > 1: first = 0 second = 1 - if nodes[first].frequency>nodes[second].frequency: + if nodes[first].frequency > nodes[second].frequency: first, second = second, first - for i in range(2,len(nodes)): - if nodes[i].frequency