diff --git a/u9/huffman_tree.py b/u9/huffman_tree.py index edddfd2..b82dbdf 100644 --- a/u9/huffman_tree.py +++ b/u9/huffman_tree.py @@ -28,13 +28,10 @@ class HuffmanTree: 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: - second = first - first = i + if nodes[i].frequency < nodes[first].frequency: + second = first + first = i elif nodes[i].frequency < nodes[second].frequency: second = i