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
2
votes
1 answer

Java - My Huffman decompression refuses to decompress non-text files (returns empty file)

I am able to compress all kinds of files (.jpg, .mp4 etc.) but when I try to decompress these non-text files the program just returns an empty decompressed file... the weird part is that I am able to decompress plain text files just fine. When I…
Schytheron
  • 715
  • 8
  • 28
2
votes
1 answer

Can I apply Huffman Coding again and again?

I was wondering can I apply Huffman coding again and again ? For example, File A ---> (Huffman) ---> File B (smaller size than A) File B ----> (Huffman) ---> File C ? Is it logically correct to apply Huffman again on File B output.?
Sagar
  • 2,315
  • 7
  • 25
  • 34
2
votes
1 answer

How do i run gzip compression with static huffman ( aka BTYPE=01)

I could not find the gzip command line for generating a compressed output with a fixed/static huffman encoding ( aka BTYPE=01 in the gzip format). Can someone please help with the options i can use for this?
2
votes
1 answer

Generating Huffman Tables for Motion JPEG on FPGA

Iam working on a FPGA implementation of MJPEG Encoder which uses standard quantisation and huffman tables. Question: Can we generate Huffman tables on fly ?. I mean that once a frame is given as input, a block in the FPGA should generate…
vikram9866
  • 91
  • 4
2
votes
1 answer

Must a node's right subtree's frequency bigger than left subtree's frequency in a huffman tree?

Can the left subtree's frequency bigger than the right?
guo
  • 9,674
  • 9
  • 41
  • 79
2
votes
1 answer

How can I use splay tree data structure in huffman coding for data compression?

First of all, I am new to programming, so I would expect simple and well explained answers. Secondly this is a very specific question and I don't want moderators and other users to just close this question as off-topic or for being too broad.…
user5987642
2
votes
2 answers

How does this code result in the string "nginx"?

I've been trying to study the nginx source code for a while. Recently, Nginx 1.9.12 was released and with that they implemented "Huffman encoding of response headers in HTTP/2". In this release, I'm unable to understand the this one line, static…
user3418870
2
votes
1 answer

Are there multiple ways to do Huffman encoding?

So I made a program that should do Huffman encoding. When comparing my answers to the correct ones, not all of mine matched up. I got [("a","0"),("c","100"),("b","101"),("d","110"),("f","1110"),("e","1111")] The correct answer is…
error_null_pointer
  • 457
  • 1
  • 6
  • 21
2
votes
2 answers

Is there any tree for optimal prefix code other than Huffman tree? Will the height of that be the same as that of Huffman tree?

I have known that Huffman Tree is a kind of tree used for optimal prefix code, but is there any tree for optimal prefix code other than Huffman tree? If there are some that kind of trees, will their heights be the same? Many thanks!
2
votes
1 answer

Do jpeg standard fixed huffman tables really reduce data size?

I 'm implementing jpeg compression for microcontroller. In the huffman coding step I decided to use the standard fixed huffman table. I 've read somewhere that these tables are suitable for general images, but cannot find a statistical number about…
qand
  • 49
  • 1
  • 9
2
votes
2 answers

Building a Huffman tree

I've been working on this Huffman tree builder: // variable al is an array list that holds all the different characters and their frequencies // variable r is a Frequency which is supposed to be the roots for all the leaves which holds a null string…
Zieklecknerizer
  • 275
  • 3
  • 6
  • 15
2
votes
5 answers

Huffman Tree Encoding

My Huffman tree which I had asked about earlier has another problem! Here is the code: package huffman; import java.io.FileNotFoundException; import java.io.FileReader; import java.util.ArrayList; import java.util.PriorityQueue; import…
Zieklecknerizer
  • 275
  • 3
  • 6
  • 15
2
votes
1 answer

How to calculate the size of a BitSet in bytes?

I used a Java BitSet to encode a message. My compressed file size comes out to 954kb, but when I do BitSet.cardinality(), I get around 4mb. Can you explain this?
user104827
  • 57
  • 6
2
votes
1 answer

Building a Huffman tree from a binary search tree

I am trying to build a huffman tree out of binary search tree. Sadly my code is crashing (Segmentation fault (core dumped)). This is how the struct is defined: struct Node { unsigned char m_ch; int m_freq; struct Node *m_ls,*m_rs; struct…
2
votes
1 answer

Huffman vs adaptive huffman

I know that adaptive huffman has better performance than huffman algorhitm, but I can't figure out why. In Huffman, when you build a tree and encode your text, you must send frequencies for each letter in text with encoded text. So when decoding,…
user2090925
  • 65
  • 3
  • 10