For this week we ask you to make a coding algorithm based adaptive Huffman coding.
Try to modify my above code to make it adaptive only manage to finish a bit to read me the frequency of characters within a compressed textro something that was not yet finished.
Remembering some algorithm process:
1. We look for the frequency of unique characters in the text above.
2. Each of the characters is created as a tree and add them to a list, each tree has its associated symbol and frequency number.
3. The ordered from lowest to highest according to the frequencies.
4. From the above it will select the first two trees from the list and will form a new tree with them, before the tree will delete the two trees in the list. The root of the new tree will be the sum of the frequencies of the roots of the two trees to be joined and the trees will now child nodes of this.
5. We add to the list the new tree created by ordering from low to high
6. Already having obtained the tree end we have to begin to explore it in order to get the binary code of each of the characters, as we know is a binary tree that has the following tags that link one node to another.
The idea to make a little adaptive was possible to continue updating the tree and updates during ordering property is maintained, for example, nodes (internal and leaves) were ordered according to increasing their weights.
When it is necessary to exchange the farthest node with a certain weight is exchange with the node whose weight is increased.
Be tree could be seen differently when exchanging nodes and perform better compression level and still have the same efficiency.
But the program didn't work :(