You are viewing a single comment's thread. Return to all comments →
def decodeHuff(root, s): #Enter Your Code Here code = '' start = 0 end = 0 n = len(s) node = root #print(node.left.data) while end < n: # print(code) # print(end) if node.left or node.right: if s[end] == '0': node = node.left else:#=1 node = node.right end+=1 else:#stop letter # print('stop letter') code = code + node.data node = root code = code + node.data#Last potential letter excluded from loop print (code)
def decodeHuff(root, s): #Enter Your Code Here
code = '' start = 0 end = 0 n = len(s) node = root #print(node.left.data) while end < n: # print(code) # print(end) if node.left or node.right: if s[end] == '0': node = node.left else:#=1 node = node.right end+=1 else:#stop letter # print('stop letter') code = code + node.data node = root code = code + node.data#Last potential letter excluded from loop print (code)
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 →