1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

huffman tree c++

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

  1. macrumors regular

    FuuFuu

    #1
    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
     
  2. macrumors 68040

    lee1210

    #2
    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
     
  3. macrumors 603

    #3
    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.
     
  4. macrumors 68000

Share This Page