Posted 12 May 2005 - 06:44 AM
I write it to compress a file to save space.
Such as the letters in English,they appeared in a file holding different frequences.
For example,"A" appeared 77 times,"B" appeared 17 times.Some letters had little
frequency,so using this fact we can make a new file.The previous file use the ASC codes to translate the letters into binary numbers,so the letters can be store in the memory.But the new file doesn't use the ASC codes,it uses the Huffman codes to translate the letters into binary numbers,which are stored in the memory.
In ASC every letter having been translated into binary number is assigned 8 bytes.But in Huffman's theory,not all the letters are allocated 8 bytes.Some letters take more than 8 bytes,some take less than 8 bytes.It really make effects,and it can save the space.
If you are interesting in the Huffman Tree,you'd better find a book about this to read.