huffman code

Reply

Join Date: Aug 2004
Posts: 13
Reputation: apurva agarwal is an unknown quantity at this point 
Solved Threads: 0
apurva agarwal apurva agarwal is offline Offline
Newbie Poster

huffman code

 
0
  #1
Aug 28th, 2004
hi!!
i want to know about the huffman algoriyhm and its implementation.
how the huffman code works and its use, a code in c/c++ language
TO RISE TO GREAT HEIGHT ONE MUST GO TO GREAT DEPTH
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 436
Reputation: Chainsaw is an unknown quantity at this point 
Solved Threads: 10
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

Re: huffman code

 
0
  #2
Aug 28th, 2004
Huffman was a guy who realized that letters do not occur statisticly randomly; 'e' is used a lot more than 'j'. He figured you could build a balanced tree of letters (or anything else that occurs non-randomly, like words) and using that tree, represent letters in a minimal number of bits.

The original Huffman went like this:
1) count the occurances of the letters in your text to be compressed
2) build a binary tree such that the shortest paths in the tree go to the most referred-to letters
3) encode the tree as bits, where a 0 means go LEFT on the tree and 1 means go RIGHT.

Later variants allowed the tree to be built dynamically as you see the charactors, as in processing a stream of bytes.

Huffman is used as the post-processing in many compressors, like gzip (which first removes blocks of common letters and then Huffmanizes the result) and jpeg (which converts pixels into cosine values and Huffmanizes the resulting (nearly the same) values).

Google will get you to some sample code easily. Now that you know the basics, the code should be pretty readable.

Good luck!
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 13
Reputation: apurva agarwal is an unknown quantity at this point 
Solved Threads: 0
apurva agarwal apurva agarwal is offline Offline
Newbie Poster

Re: huffman code

 
0
  #3
Aug 28th, 2004
thanks a lot !!!!
but i have a problem with the code i have counted the frequency but i am not able to build the heap which i have to build to finally make a tree.
help me here!!!!
TO RISE TO GREAT HEIGHT ONE MUST GO TO GREAT DEPTH
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 436
Reputation: Chainsaw is an unknown quantity at this point 
Solved Threads: 10
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

Re: huffman code

 
0
  #4
Aug 30th, 2004
Google is your programming friend! Here's what I found with "Huffman algorithm":

http://ciips.ee.uwa.edu.au/~morris/Y...0/huff-op.html

Looks like just what you want!
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 3
Reputation: Alex Vinokur is an unknown quantity at this point 
Solved Threads: 0
Alex Vinokur Alex Vinokur is offline Offline
Newbie Poster

Re: huffman code

 
0
  #5
Aug 30th, 2004
Originally Posted by apurva agarwal
hi!!
i want to know about the huffman algoriyhm and its implementation.
how the huffman code works and its use, a code in c/c++ language
Look at n-ary Huffman Template Algorithm
* http://alexvn.freeservers.com/s1/huf...algorithm.html
* http://sourceforge.net/projects/huffman-ta/
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 1
Reputation: devangat20 is an unknown quantity at this point 
Solved Threads: 0
devangat20 devangat20 is offline Offline
Newbie Poster

Re: huffman code

 
0
  #6
Oct 3rd, 2004
Originally Posted by apurva agarwal
hi!!
i want to know about the huffman algoriyhm and its implementation.
how the huffman code works and its use, a code in c/c++ language
I would be highly grateful if u give me the code
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,541
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 704
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: huffman code

 
0
  #7
Oct 3rd, 2004
>I would be highly grateful if u give me the code
I'm sure you would. Do your own work, it's much more rewarding.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 1
Reputation: nbrmkumaresh is an unknown quantity at this point 
Solved Threads: 0
nbrmkumaresh nbrmkumaresh is offline Offline
Newbie Poster

Re: huffman code

 
0
  #8
Jan 28th, 2005
Please give me an idea of how to do program the huffman code in C
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,862
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 870
Moderator
vegaseat's Avatar
vegaseat vegaseat is online now Online
DaniWeb's Hypocrite

Re: huffman code

 
0
  #9
Jan 28th, 2005
Originally Posted by nbrmkumaresh
Please give me an idea of how to do program the huffman code in C
Check the C code snippet right here on DaniWeb:
http://www.daniweb.com/code/snippet5.html

Test it, improve it, learn from it!
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 248
Reputation: hammerhead is an unknown quantity at this point 
Solved Threads: 24
hammerhead's Avatar
hammerhead hammerhead is offline Offline
Posting Whiz in Training

Re: huffman code

 
0
  #10
Apr 23rd, 2008
Stop begging for code. Do your own work and read this thread http://www.daniweb.com/forums/announcement8-2.html
There are 10 types of people in the world, those who understand binary and those who don't.

All generalizations are wrong. Even this one.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC