Tree: Huffman Decoding

  • + 0 comments
    def decodeHuff(root, s):
    	#Enter Your Code Here
        string = ""
        cur = root
        for si in s:
            if si == '0':
                cur = cur.left
            elif si == '1':
                cur = cur.right
            if cur.left is None and cur.right is None:
                string += cur.data
                cur = root
                
        print(string)