Prove that a uniquely decodable binary scheme hast the average code word length $l = H(S)$ iff all $p_i$ are powers of $\frac{1}{2}$.

32 Views Asked by At

I would like to prove the above.
In this notation $\displaystyle H(S) = \sum_{i = 1}^m p_i \log_2(p_i)$ is the entropy.
My idea is to write $l$ as $\displaystyle l = \sum_{i = 1}^m p_i l_i + \log_2(G) \cdot \sum_{i = 1}^m p_i $, where $\displaystyle G = \sum_{i = 1}^m 2^{- l_i}$.
And use that $\log_2(G) = 0$.
Is that a good approach? And if so has someone an idea how i would prove $G = 1$?