What is the definition of a prefix-free code?
A prefix-free code is a code in which no codeword appears as the initial segment (prefix) of any other codeword. For every pair of distinct codewords, neither may begin with the other as a prefix.
Conditions
- Defined relative to concatenation of binary strings.
- For every pair of distinct codewords , , neither is a prefix of nor is a prefix of .
Reasoning, step by step
- List all codewords assigned to the source symbols under the code.
- For each pair of distinct codewords, check if one is a prefix of the other.
- Verify that no such prefix relation exists.
- Conclude that the code is prefix-free.
Example
In the displayed table, Codes 1, 2, and 4 are prefix-free. Code 3 is not prefix-free because the codeword 0 for is a prefix of 00 for , and the codeword 1 for is a prefix of 11 for .
Common misconceptions
- Assuming that prefix-free codes must be fixed-length.
- Confusing prefix-free codes with distinct codes; a code can be distinct but not prefix-free.
Watch the explanation
Explore next
Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.