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.
Root is stored and never changes, so you can go back there after you reach a leaf. The variable "temp" stores the current position as you traverse down towards a leaf.
Once you reach a leaf, identified by the lack of left/right links, you retrieve the data and add it to your string. Then you need to reset your position to the root node, so you set temp=root.
Tree: Huffman Decoding
You are viewing a single comment's thread. Return to all comments →
Not my code but I did something similar.
Root is stored and never changes, so you can go back there after you reach a leaf. The variable "temp" stores the current position as you traverse down towards a leaf.
Once you reach a leaf, identified by the lack of left/right links, you retrieve the data and add it to your string. Then you need to reset your position to the root node, so you set temp=root.