Tree: Huffman Decoding

  • + 0 comments

    Python Solution

    It is just a translation of tom_linteau's solution which is in java. it is acording to me very short an sipmle to understand.

    Hier is it in python

    def decodeHuff(root, s):
    	#Enter Your Code Here
      curr = root
      for i in range(0,len(s)):
        if s[i]=='0':
          curr = curr.left
        else:
          curr = curr.right
        
        if curr.left is None and curr.right is None:
          print(curr.data,end='')
          curr = root