🌱
A prefix code (or prefix-free or instantaneous code) is a VLC for which none of its codewords is a prefix of another codeword.
A prefix code is UD since none of its codewords can be at the beginning of another codeword: as soon as we look at a sequence of codewords, we can directly delineate the codewords (from left to right) and separate them (via commas) as they are immediately recognizable.
1. Every -ary n-th order prefix VLC for a discrete source of alphabet has codeword lengths satisfying the Kraft Inequality of base 2. Conversely, given a set of positive integers that satisfy the Kraft Inequality of base , there exists a -ary n-th order prefix VLC for the source with codeword lengths .
Let be an optimal -th order code for the source with the class of prefix codes (i.e. for all prefix codes ). Then is also optimal within the entire class of UD codes (i.e. for all UD codes ).
Let be an optimal binary prefix code with codeword lengths for a source with alphabet and symbol probabilities (). Without loss of generality, assume and that any group of source symbols with the same probability is arranged in the order of increasing codeword lengths (i.e., if ) then ). Then the following properties hold: 1. Higher probability source symbols have shorter codewords: 2. The two least probable source symbols have codewords of equal lengths: 3. Among the codewords of length , two of them are identical except in the last digit.