Questions tagged [huffman-code]

Huffman coding is a lossless compression algorithm that is optimal, assuming all input characters are drawn from a known discrete distribution.

Huffman coding is an algorithm that builds a variable-length, prefix-free code for each character in an alphabet based on the frequency of that character. The algorithm works by greedily assembling an encoding tree by combining together encoding trees for individual characters based on their weights. Low-weight trees are combined together until only a single tree remains.

Useful links

1053 questions
39
votes
6 answers

Efficient way of storing Huffman tree

I am writing a Huffman encoding/decoding tool and am looking for an efficient way to store the Huffman tree that is created to store inside of the output file. Currently there are two different versions I am implementing. This one reads the entire…
X-Istence
  • 16,324
  • 6
  • 57
  • 74
33
votes
2 answers

Read a file as byte array

I have an assignment for coding a Huffman algorithm. I have the whole problem organized in my head, but I'm having some trouble with file handling. The problem is: the algorithm is supposed to compress ANY kind of file. My solution: read the file as…
alissonlacerda
  • 351
  • 1
  • 3
  • 6
31
votes
5 answers

What is the best compression algorithm that allows random reads/writes in a file?

What is the best compression algorithm that allows random reads/writes in a file? I know that any adaptive compression algorithms would be out of the question. And I know huffman encoding would be out of the question. Does anyone have a better…
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
29
votes
6 answers

What are the real-world applications of huffman coding?

I am told that Huffman coding is used as loseless data compression algorithm, but I am also told that real data compress software do not employ Huffman coding, because if the keys are not distributed decentralized enough, the compressed file could…
Jichao
  • 40,341
  • 47
  • 125
  • 198
14
votes
1 answer

malloc: *** error for object: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug

Can someone help me figure out where I'm getting this error. I know it's probably a double deletion or something like this. For the background this is an implementation of the huffman's tree as you can easily realize on wikipedia. CharCountNode…
waldyr.ar
  • 14,424
  • 6
  • 33
  • 64
14
votes
1 answer

Decoding a JPEG Huffman block (table)

The following block is nested by Huffman block markers -HUFF---------------------------------------------------------------------0084- 10 0 1 2 4 3 4 6 5 6 8 a 9 4 2 3 0 1 2 11 0 3 4…
Supernovah
  • 1,946
  • 12
  • 34
  • 50
13
votes
2 answers

Lossless compression method to shorten string before base64 encoding to make it shorter?

just built a small webapp for previewing HTML-documents that generates URL:s containing the HTML (and all inline CSS and Javascript) in base64 encoded data. Problem is, the URL:s quickly get kinda long. What is the "de facto" standard way…
bennedich
  • 12,150
  • 6
  • 33
  • 41
13
votes
6 answers

How to decode huffman code quickly?

I have implementated a simple compressor using pure huffman code under Windows.But I do not know much about how to decode the compressed file quickly,my bad algorithm is: Enumerate all the huffman code in the code table then compare it with the bits…
Jichao
  • 40,341
  • 47
  • 125
  • 198
13
votes
1 answer

Writing files in bit form to a file in C

I am implementing the huffman algorithm in C. I have got the basic functionality down up to the point where the binary codewords are obtained. so for example, abcd will be 100011000 or something similar. now the question is how do you write this…
sfactor
  • 12,592
  • 32
  • 102
  • 152
12
votes
3 answers

Is it possible to achieve Huffman decoding in GPU?

We have a database encoded with Huffman coding. The aim here is to copy on the GPU it with its associated decoder; then on the GPU, decod the database and do stuff on this decoded database without copying back it on the CPU. I am far to be a Huffman…
Jérôme
  • 2,640
  • 3
  • 26
  • 39
11
votes
1 answer

Optimized order of HTML attributes for compression

I read somewhere that organizing HTML attributes in a certain order can improve the rate of compression for the HTML document. (I think I read this from Google or Yahoo recommendation for faster sites). If I recall correctly, the recommendation was…
StackOverflowNewbie
  • 39,403
  • 111
  • 277
  • 441
11
votes
5 answers

How can I create a tree for Huffman encoding and decoding?

For my assignment, I am to do a encode and decode for huffman trees. I have a problem creating my tree, and I am stuck. Don't mind the print statements - they are just for me to test and see what the output is when my function runs. For the first…
xevaaa
  • 127
  • 1
  • 1
  • 6
10
votes
1 answer

Jpeg restart markers

I made jpeg decoder, but I didn't implement restart markers logic. That is reason why my program don't work on some images (for example images saved with Photoshop: File->Save As->jpeg). I want to implement restart marker logic, but there is no…
MrD
  • 2,423
  • 3
  • 33
  • 57
9
votes
3 answers

Converting a String representation of bits to a byte

I'm just beginning to learn about file compression and I've run into a bit of a roadblock. I have an application that will encode a string such as "program" as a compressed binary representation "010100111111011000"(note this is still stored as a…
John Lotacs
  • 1,184
  • 4
  • 20
  • 34
9
votes
2 answers

Huffman suffix-code

I'm trying to efficiently construct a binary suffix code for a given set of characters with their probabilities (i.e. a set of words none of which is a suffix of any other). My basic idea is to construct a prefix-code using an implementation of the…
Tobias Geiselmann
  • 2,139
  • 2
  • 23
  • 36
1
2 3
70 71