Tree: Huffman Decoding

  • + 0 comments

    Python 3 Solution

    def decodeHuff(root, s):
        n = root
        for l in s:
            if l == "0":
                n = n.left
            elif l == "1":
                n = n.right
    
            if n.left == None and n.right == None:
                print(n.data, end="")
                n = root