Binary prefix free code satistying Kraft inequality with equality

information theory

Consider a binary prefix free code of $M$ codewords of length $l_1,\cdots,l_M$ satisfying the Kraft inequality with equality, i.e. $$\sum_{i=1}^M 2^{-l_i}=1$$.
Show that the size of any codeword is lesser or equal than $M-1$.

I tried to begin this question by assuming there exists a codeword of length $M$ and try to verify the implications for the tree representation of a code, but I'm not getting anywhere. Any help would be appreciated.

Best Answer

Call $2^{-l}$ the weight of a codeword of length $l$.

The fastest way to get a long codeword (one of small weight) is to divide the unit interval into two repeatedly. So weights $1/2, 1/4, 1/8, 1/16, 1/32, 1/32$ for example.

To get a codeword of weight $1/2^r$ you need at least another of length $r$ and then one of length $2^{r-1}$ (or smaller ones that add up to this) and so on. So you need at least $r+1$ codewords to have a length $r$ codeword.

Related Question