You are viewing a single comment's thread. Return to all comments →
Python solution:
def is_leaf(node): return node.left is None and node.right is None def decodeHuff(root , s): current = root result = [] index = 0 while index < len(s): while not is_leaf(current): if int(s[index]) > 0: current = current.right else: current = current.left index += 1 result.append(current.data) current = root print(''.join(result))
Seems like cookies are disabled on this browser, please enable them to open this website
Tree: Huffman Decoding
You are viewing a single comment's thread. Return to all comments →
Python solution: