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)

I don't see how exactly your solution is different. Additionaly, temp has a local scope and leaves the root un bothered in the original solution. I can't really see how your solution improved the former

## 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 variable`head`

should be left untouched and a new variable, forexample`current_node`

or just`node`

should be used to traverse the tree down.I don't see how exactly your solution is different. Additionaly,

`temp`

has a local scope and leaves the`root`

un bothered in the original solution. I can't really see how your solution improved the former