| | |
Huffman Algorithm In C.
![]() |
•
•
Join Date: Feb 2008
Posts: 3
Reputation:
Solved Threads: 0
I Am Working On A Project Related To Data Compression Using Huffmann Algorithm In C Language..........i Have Generated The Huffmann Codes Using Huffmann Tree.........but The Project Is Yet To Be Completed As I Don`t Know How To Store The Codes In Bits.............i Have Just Learned C.
We Have To Submit The Project By 28 Th Feb............so Expecting A Quick Response...............
We Have To Submit The Project By 28 Th Feb............so Expecting A Quick Response...............
Usually you will have yourself a little function that takes a specific number of bits (let's say just one bit at a time for each branch in the tree).
The function will modify a static "bits" variable (say, one byte) by shifting in the new bit, and incrementing another static "count" variable that keeps track of the number of bits stored in the byte. Once the counter hits eight (for one byte == eight bits), the byte is written to the output stream, and the "bits" and "count" variables are reset to zero.
You will also need a "final" function that flushes bits remaining when your huffman stream doesn't produce a multiple of eight bits (since the last byte won't be completely filled, but it must still be output).
Hope this helps.
The function will modify a static "bits" variable (say, one byte) by shifting in the new bit, and incrementing another static "count" variable that keeps track of the number of bits stored in the byte. Once the counter hits eight (for one byte == eight bits), the byte is written to the output stream, and the "bits" and "count" variables are reset to zero.
You will also need a "final" function that flushes bits remaining when your huffman stream doesn't produce a multiple of eight bits (since the last byte won't be completely filled, but it must still be output).
Hope this helps.
Glad you found a possible solution.
If you're going to stick around could you do us a favor?
Could you stop Capitalizing at random some ( most ) of the words? It makes your post hard to read.
And we could live without the ..................... as well, it doesn't do anything to enhanced your
writing, but the contrary is true.
If you're going to stick around could you do us a favor?
Could you stop Capitalizing at random some ( most ) of the words? It makes your post hard to read.
And we could live without the ..................... as well, it doesn't do anything to enhanced your
writing, but the contrary is true.
![]() |
Similar Threads
- Huffman Coding (Java)
- huffman code (C++)
- Huffman Code Comments, I need help with putting in the comments to this code,needhelp (C++)
- Need for a new Algorithm (C)
- Traversing a Huffman Tree (C++)
- Please anyone help tweak my code The code tags are around it now (Java)
- Please anyone help tweak my code (Java)
Other Threads in the C Forum
- Previous Thread: newbie question about return
- Next Thread: help with functional definition in c
| Thread Tools | Search this Thread |
#include * ansi array arrays asterisks bash binarysearch centimeter changingto char character convert copyimagefile cprogramme creafecopyofanytypeoffileinc createprocess() database dynamic execv feet fgets file floatingpointvalidation fork function getlogicaldrivestrin givemetehcodez grade gtkwinlinux hacking histogram ide inches include incrementoperators infiniteloop initialization input interest intmain() iso kernel keyboard kilometer km license linked linkedlist linux list lists locate looping lowest matrix meter microsoft number oddnumber open opendocumentformat openwebfoundation owf pdf pointer pointers posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprograming socketprogramming standard strchr string suggestions systemcall test threads turboc unix urboc user variable wab whythiscodecausesegmentationfault windowsapi






