Thread: Huffman Trees

  1. #1
    Chad Johnson
    Join Date
    May 2004
    Posts
    154

    Huffman Trees

    I am writing a program to compress a text file using huffman trees.

    I realized that if the tree is of a level greater than or equal to eight, there will be no compression occurring.

    Do I have to limit the size of the trees? Do I have to make a tree for every 32 bits or something?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > I realized that if the tree is of a level greater than or equal to eight, there will be no compression occurring.
    How so?
    A 9-bit huffman code is just as valid as a 3-bit huffman code
    It all depends on the size of your "alphabet"

    If you just go with letters, you end up with at most 52 letters in your frequency table
    If you also count letter pairs, then you'll have a lot more to count, but also many more combinations which will never occur.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trees
    By masterg in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2008, 01:42 PM
  2. huffman tree
    By blazer26 in forum C Programming
    Replies: 0
    Last Post: 04-25-2006, 03:39 PM
  3. Huffman coding
    By misplaced in forum C++ Programming
    Replies: 2
    Last Post: 04-21-2005, 01:14 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Huffman compression
    By SMurf in forum C Programming
    Replies: 2
    Last Post: 09-01-2001, 07:30 AM