EMERGENCY HELP !! Huffman Tree. Totally Confused Where to Start.

/**
* This method is called to generate your tree. The return type is void because this method simply creates the tree. The other methods
* will be used to encode or decode the message.
*
* @param message The message that should be used to create the tree
*/
void createTree(string message)
{
}

I have been given this code. I am totally confused on where to start. I have to create a Huffman Tree with a string of message such as.
"muckduck! muuuud draumak pmdap dp ucmr, paumeu dpapkam. mka. rpkuakdap pamk aprckpku.arp pruak, dcd ckap! r! p! .!mrp"
But I do not know where to start.

Please help. Its due in 8 hours.
I need to know how to count the frequency of the individual letters like
There is 10 "m", 8 "k", for example.
I do not know how to make my program identify that.
6 hours to go. At least post your attempt to get help here.
I think I only need help identifying the number of each characters in a string. Then I should be good to go. Ifinished everything else such as writing the encoding, decoding formulas.
I think I only need help identifying the number of each characters in a string


Well that shouldn't be too difficult for you to iterate through the string and build up a count of each character. The way I would do it would be to have an array of 'int's of size 26, use each ASCII value as the index...
That is my problem I have no idea how to do it.
I have to later store the data in this structure.

struct Data
{
int weight; //the frequency the letter occurs
char letter;
Data(int w, char c) : weight(w), letter(c) {}
};
Topic archived. No new replies allowed.