PDA

View Full Version : huffman tree c++




FuuFuu
Sep 25, 2010, 12:46 PM
hey everyone, i have a project to make a huffman tree, to compress it and to uncompress it also. but first i must make the huffman tree. i'm not really sure the best way to store each frequency for each letter. im given a a huge text that i stored in textedit and im doing this on xcode. i thought it was just gonna be a char array and compare to every letter from the alphabet to each char from the text but they doesnt work cause i can't store the frequency lol. please help.


thanks



lee1210
Sep 25, 2010, 01:30 PM
The most trivial would be an array of ints or longs where the position in the array corresponds to the numerical representation of the character in your encoding. Just count[char]++.

-Lee

chown33
Sep 25, 2010, 01:42 PM
Get the book "Algorithms" by Robert Sedgewick. It's actually a series of books, targeted to specific languages, sometimes with collaborators.

It's not a cheap book, unless you find it used, but it's one that will repay its price many times over. The writing is very clear, the algorithms are described well, and the graphics are excellent. It specifically covers Huffman trees, among many other useful algorithms and data structures.

I still have my original single-volume "Algorithms in C", which was expanded to multiple volumes later. The single-volume one covers the same topics as the multi-volume sets, but in a single book.

robvas
Sep 25, 2010, 09:32 PM
http://en.literateprograms.org/Huffman_coding_%28C_Plus_Plus%29