This algorithm consists in the creation of a binary tree in which each of the leaves contain a character string to compress with the frequency whit which it is repeated in the character string.
Based on the assignment of codes to different bit length of each character composing a text string. If short codes are assigned to the characters that appear more often, you get a greater understanding of the text string.
I give the input character string, in this case use the next line of text for example:
1. Characters ordered from lowest to highest according to the number of times they are repeated.
2. We create a new tree root that contain the character with their respective number of frequency in the chain and insert the tree in a tree list.
3. Each of the characters as a tree is created and added to a list, each tree has its associated symbol and frequency number.
4. From the above it will select the first two trees from the list and will form a new tree with them:
5. The root of the new tree will be the sum of the frequencies of the roots of two trees to be joined and tree are now child nodes
6. It adds to the list the new tree created by ordering from lowest to highest
7. It gets to select two trees from the list and will form a new tree with them, before the tree realiar delete the two trees of the list, until a single tree in the list.
Not operate properly but here is some code that would make these processes.