Uniquely Decodable Huffman Codes: What to Know

  • Thread starter Thread starter hhhmortal
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around the concept of uniquely decodable Huffman codes, focusing on how to determine if a given set of code words is uniquely decodable. Participants explore the implications of prefix codes and the decoding process, as well as the conditions under which codes may not be uniquely encodable.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant expresses confusion about how to determine if a Huffman code is uniquely decodable, asking for clarification.
  • Another participant explains that uniquely decodable means a bit pattern does not represent more than one possible coding of data, suggesting a method of decoding all combinations of the longest code sequence.
  • A participant describes the decoding process using an example with specific code words, emphasizing that the algorithm reads from left to right and stops when a match is found, asserting that this method ensures unique decodability.
  • Some participants argue that as long as different characters have different prefixes, the code will always be uniquely decodable, while providing counterexamples where prefixes overlap, leading to ambiguity.
  • There is a suggestion that determining unique decodability could involve modifying the bit strings and checking for matches, although this method's effectiveness is not universally accepted.

Areas of Agreement / Disagreement

Participants generally agree that unique prefixes are essential for unique decodability, but there is disagreement on the methods to determine unique decodability and the implications of certain coding schemes. The discussion remains unresolved regarding the best approach to assess unique decodability.

Contextual Notes

Some participants mention that the direction of reading (left to right vs. right to left) affects the decoding outcome, indicating a potential limitation in understanding the implications of prefix codes. There are also unresolved questions about the sufficiency of certain methods for determining unique decodability.

hhhmortal
Messages
175
Reaction score
0
Hi, I'm quite stuck in understanding a certain feature of the huffman code. Basically how do I know that the code is uniquely decodable?

For example if I'm given symbols with different code words for each symbol, which would be uniquely decodable?


Thanks.
 
Technology news on Phys.org
hhhmortal said:
Hi, I'm quite stuck in understanding a certain feature of the huffman code. Basically how do I know that the code is uniquely decodable?
This just means that a bit pattern doesn't represent more than one possible coding of data, that two or more different codes would produce the same bit pattern and therefore not be unique. One test would be to decode all bit combinantions of the longest code sequence plus a few bits. Normally the leading bit pattern, usually all 0 or or all 1 bits, determines the length of current code word.
 
The way it works is by having unique prefixes. What does that mean?

Let's say you have the following:
a :: 1
b :: 00
c :: 011
d :: 010

Now I give you a string of bits,

010100001111010101000101110100100101001010101001

How is this uniquely decodable? Well, we start reading from the left, and keep going to the right. We stop when the accumulated bits in the current string matches one of the entries in the table.

So here we go...
0
01
010 => becomes 'd'
1 => becomes 'a'
0
00 => becomes b
etc.

Basically, it's uniquely decodable because of the way the algorithm works, left to right, with prefix strings.

If you're asking whether or not things are uniquely encodable using Huffman's algorithm... they're not!
 
AUMathTutor said:
The way it works is by having unique prefixes. What does that mean?

Let's say you have the following:
a :: 1
b :: 00
c :: 011
d :: 010

Now I give you a string of bits,

010100001111010101000101110100100101001010101001

How is this uniquely decodable? Well, we start reading from the left, and keep going to the right. We stop when the accumulated bits in the current string matches one of the entries in the table.

So here we go...
0
01
010 => becomes 'd'
1 => becomes 'a'
0
00 => becomes b
etc.

Basically, it's uniquely decodable because of the way the algorithm works, left to right, with prefix strings.

If you're asking whether or not things are uniquely encodable using Huffman's algorithm... they're not!

Oh right this makes perfect sense. Is there an easier way to determine if that alphabet you just mentioned is uniquely decodable or not? ..I've been trying to do it this way:

By adding a 1 or 0 at the end of the bit string of every symbol and seeing if they would match the others..If it does it wouldn't be unique?
 
As long as different characters have different prefixes, it will *always* be uniquely decodable. For instance, the following wouldn't work:

a :: 1
b :: 10
c :: 01
d :: 011

Why not? Because "a" is a prefix for "b". You wouldn't know whether to go with "a" when you reach it or keep going. Same for "c" and "d".

Under any scheme, if you start from the right and go left, for instance, you will get a different result than if you go left to right. In that sense, no scheme is uniquely decodable.

But making sure that no string is a prefix for another, and matching from left to right, it always works. Because you never have to ask, because once you can tell, it couldn't end up being something else.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
1
Views
6K
  • · Replies 0 ·
Replies
0
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
3
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 1 ·
Replies
1
Views
7K
Replies
10
Views
2K