The 2024 Developer Survey results are live! See the results

# Tag Info

Accepted

### Any algorithm to do Huffman encoding without using graphs?

If you're allowed to reorder the symbols, then the answer is yes. We'll approach this in three stages. Linear-time Huffman tree construction First things first. If the symbols are sorted into order of ...
• 22.6k

### Huffman Coding vs LZW Algorithm

In a gist LZW is about frequency of repetitions and Huffman is about frequency of single byte occurrence. Take the string 123123123. (The following is an oversimplification but will make the point) ...
• 191

### Maximum size of Huffman codes for an alphabet containing 256 letters

I don't see how to approach the problem. OK, here is how you can approach the problem. Can you solve this problem if you replace the number 256 with the number 3? How about 4? 5? Try solving ...
• 163k

### How does a predictive coding aid in lossless compression?

Huffman coding, as usually applied, only considers the distribution of singletons. If $X$ is the distribution of a random singleton, then Huffman coding uses between $H(X)$ and $H(X)+1$ bits per ...
• 278k

### Is huffman-encoding with distinct frequencies of symbols unique?

2 3 4 5 is a counterexample: 4 5 5 (combine 2 and 3 to make 5, and reorder) Now there are 2 choices for ...
• 5,479

• 278k

### Compression of a text that contains only the 5 first letters of the alphabet?

If you look at the algorithm for creating Huffman trees/codes, you will see that while it uses frequencies, any weight works. You can always rescale (by dividing by the sum of all weights), if you ...
• 72.7k

### Huffman Code VS Hu–Tucker Code

Let's say you wanted to compress a dictionary using Huffman Algorithm, yes it would be small, but all the ordering would disappear. So if you wanted to get the definition of for example the word '...
• 21

### Is there a generalization of Huffman Coding to Arithmetic coding?

As a simple example, if you had three symbols with probability 1/3rd each, your optimal Huffman encoding would use the three symbols 0, 10 and 11 with an average of 5/3rd bits. There are 243 symbols ...
• 31.2k

### Is It possible to change the side of 0 and 1 in Huffman tree?

Yes, You can. But you'll need the Huffman tree to decode since the placing of left child and right child is arbitrary. If you're given an encoded string and ask you to decode, you can't do that since ...
• 136
Accepted

### Is It possible to change the side of 0 and 1 in Huffman tree?

You can assign the $1$ and $0$ as you like, but be consistent. Only your code change, i.e. a 1011 becomes a 0100.
• 558