Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

FuuFuu

macrumors regular
Original poster
Jul 8, 2008
226
0
Roselle
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

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
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

Moderator
Staff member
Aug 9, 2009
10,751
8,425
A sea of green
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.