From d6a69f069615b766a68ca356471311695340a630 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 16 Nov 2026 11:49:23 +0100 Subject: [PATCH] uloha --- u9/huffman_tree.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/u9/huffman_tree.py b/u9/huffman_tree.py index c243e5c..4421a5f 100644 --- a/u9/huffman_tree.py +++ b/u9/huffman_tree.py @@ -36,4 +36,10 @@ while len(queue) > 1: if self._root is not None: self._collect_codes(self._root, "") +def _collect_codes(self, node, prefix): + if node.data is not None: + self._codes[node.data] = prefix or "0" + return + self._collect_codes(node.left, prefix + "0") + self._collect_codes(node.right, prefix + "1")