You are viewing a single comment's thread. Return to all comments →
For this type of tree, you don't have to check if both left and right leaves exist - each node has either 2 or 0 leaves.
That should let you shorten your second while statement to "while current.left:"
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 →
For this type of tree, you don't have to check if both left and right leaves exist - each node has either 2 or 0 leaves.
That should let you shorten your second while statement to "while current.left:"