miércoles, 10 de abril de 2013

Tarea #3

For this homework I worked in huffman compression algorithm, the huffman compression consist in the use of a  table of codes of variable long assigned to characters that the element to compress contains.

How works?
The algorithm consist in make a tree based in the frequency in that the characters appears in the string.

First, when we have a string we search the frequency of the characters, for example:

'Adriana'
And this is the frequency:
Then the characters are added to a list ordered from lowest to highest according to their reps.

From the list from the tree as follows:
  • First we take the first two nodes of the list and create a new node in which its root will be NULL and the sum of the number of repetitions of these two nodes.

  • Nodes taken from the list are removed and the new node is added to the list and we have as follows:


  • Repeat the process to combine the following lower nodes and get this:







Now, this is my code:
[ ]

:B 

To be continued...

References:

2 comentarios: