Questions tagged [huffman-coding]

90 questions
18
votes
4 answers

Huffman encoding: why is there no need for a separator?

Char Code ==== ==== E 0000 i 0001 y 0010 l 0011 k 0100 . 0101 space 011 e 10 r 1100 s 1101 n 1110 a 1111 Original…
BufBills
  • 291
  • 2
  • 5
12
votes
2 answers

Is there a generalization of Huffman Coding to Arithmetic coding?

In trying to understand the relationships between Huffman Coding, Arithmetic Coding, and Range Coding, I began to think of the shortcomings of Huffman coding to be related to the problem of fractional bit-packing. That is, suppose you have 240…
8
votes
2 answers

Huffman Code VS Hu–Tucker Code

Before I'll ask my question, let me start with my understanding of the definitions, to prevent myself with further confusion, as well as giving some background. Huffman Code is the binary-code induced from a binary tree, constructed by Huffman's…
so.very.tired
  • 1,259
  • 1
  • 15
  • 20
7
votes
1 answer

Any algorithm to do Huffman encoding without using graphs?

QUESTION Is there any efficient way to encode words into bits, without having to draw the graphs, solely by only using a list of probabilities? EXAMPLE This list of words: Pr('Apple') = 0.5. Pr('Banana') = 0.17. Pr('Orange') = 0.17. Pr('Pineapple')…
6
votes
3 answers

Arithmetic coding and "the optimal compression ratio"

Trying to learn more about compression techniques and found something in the wikipedia article on arithmetic coding that I'm not sure I fully grok. In describing how Huffman Coding can sometimes be inefficient, the author refers to an 'optimal…
snerd
  • 404
  • 1
  • 3
  • 9
6
votes
1 answer

Why does the Huffman coding algorithm produce a valid tree?

I am not asking about the Huffman Code, but the most widely described algorithm for generating one, also described on the english wikipedia: https://en.wikipedia.org/wiki/Huffman_coding#Compression Now, I am not really concerned with the code being…
5
votes
1 answer

Are Huffman trees and optimal binary search trees for solving the same problems?

Huffman trees are used in a specific application - Huffman coding - for finding the minimum-expected-length binary-coding for a set of strings, with respect to a probability distribution over the string set. Optimal binary search trees (as defined…
Tim
  • 5,035
  • 5
  • 37
  • 71
5
votes
1 answer

When would the worst case for Huffman coding occur?

I am doing a project on Huffman coding and wanted to know when it wouldn't be ideal to use or rather when would the Huffman coding produce low compression. Since it mainly revolves around the frequencies of the characters present in the input text,…
5
votes
2 answers

Huffman Coding vs LZW Algorithm

I'm trying to understand comparisons between the two. Is there ever a case where is it better to use Huffman Coding over LZW? Could the compression ratio for Huffman ever surpass that of LZW? Thanks!
Sheila
  • 59
  • 1
  • 1
  • 2
5
votes
0 answers

Average redundancy in Huffman or Hu-Tucker codes on random symbol probabilities

Huffman and Hu-Tucker codes are well-known compression schemes, which both come close to the entropy lower bound. It is known that if $L_1$ and $L_2$ are the lengths of a Huffman resp. Hu-Tucker code, then $H\le L_1 \le H+1$ and $H\le L_2<…
5
votes
1 answer

Optimal prefix-free binary code with several codewords already assigned

The classic Huffman algorithm, as Wikipedia states, finds an optimal prefix-free binary code with minimum expected codewords length, given a set of symbols and their weights. Now, suppose codewords for some (but not all) symbols are already assigned…
Misha
  • 151
  • 4
4
votes
2 answers

Infinite Huffman Tree

We have to derive an optimal binary encoding for the infinite set of symbols $\{s_1, s_2, \dots \}$. Their distribution is given by $$p(s_i) = 9 \cdot 10^{-i}$$ My intuition was to use a Huffman encoding. Obviously the Huffman encoding algorithm…
Enrico Borba
  • 205
  • 1
  • 5
4
votes
4 answers

Maximum size of Huffman codes for an alphabet containing 256 letters

I made a Huffman algorithm for data compression: it takes the content of a file as an input and outputs a compressed string. More important, it generates optimal prefix codes (made of 0 and 1) for every possible character, that is to say for every…
Yksuh
  • 41
  • 1
  • 1
  • 2
4
votes
1 answer

How does a predictive coding aid in lossless compression?

I'm working on this lab where we need to apply a lossless predictive coding to an image before compressing it (with Huffman, or some other lossless compression algorithm). From the example seen below, it's pretty clear that by pre-processing the…
3
votes
0 answers

Eke a better compression ratio out of Huffman coding by mixing 1-grams and 2-grams

Huffman coding is already doing a great job at compressing ascii bytes for data with a distribution like the following byte freq freq% --------------------- 0 317116 26.1 , 151471 12.5 1 112952 9.3 F 60810 5…
1
2 3 4 5 6