Zege 0 Newbie Poster

Hello,
I am working on a project for school, and the professor and I got cut short while he was explaining this to me. I am hoping I can get some advice on what to do next... here are the directions he posted:

Have your compressor class read in bytes, and count how many time each occur.
for this part I have created an array, the index is the ascii code for the read in character, and i simply add one to that index

myarray[ int c ] += 1;

Use the count data to build a Huffman tree.

this is where I am getting slightly stuck. We have a binary tree... but I am not sure how to start it. The array I have is 257 chars long, lowercase uppercase, and EOF are included in my array. I am not sure how to start making the huffman tree with this amount of data. searching the entire array for the two lowest values excluding zeros seems to be a bit of a waste of time...


Also, If i sort the data and truncate the parts of the array with 0 for data, the order is gone and I can no longer connect the count with the correct letter

Have your compressor write the Huffman tree to the output file.

not here yet...

any one have some advice for me at this stage? I would really appreciate it, if it helps i can post some of the code..

thank you for your time
~Zege

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.