huffman tree c++

Discussion in 'Mac Programming' started by FuuFuu, Sep 25, 2010.

  1. FuuFuu macrumors regular


    Jul 8, 2008
    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.

  2. lee1210 macrumors 68040


    Jan 10, 2005
    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]++.

  3. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    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.

Share This Page