We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
temp here is obviously a poor variable name choice. The variable head should be left untouched and a new variable, forexample current_node or just node should be used to traverse the tree down.
defis_last(node):returnnotnode.leftandnotnode.rightdefgo_right(node):returnnode.rightdefgo_left(node):returnnode.left# Enter your code here. Read input from STDIN. Print output to STDOUTdefdecodeHuff(root,s):result=[]node=rootforcharins:ifchar=='1':node=go_right(node)elifchar=='0':node=go_left(node)ifis_last(node):result.append(node.data)node=rootprint''.join(result)
Tree: Huffman Decoding
You are viewing a single comment's thread. Return to all comments →
temp
here is obviously a poor variable name choice. The variablehead
should be left untouched and a new variable, forexamplecurrent_node
or justnode
should be used to traverse the tree down.