= Solution
Binary <Huffman coding> repeatedly merges the two least probable current symbols, assigns opposite bits to the two children of every merge, and reads each original symbol's codeword from the root. The resulting prefix code minimizes expected word length.
The merge weights here may be chosen as
$$
.02+.03=.05,\qquad .04+.04=.08,\qquad
.05+.08=.13,\qquad .12+.13=.25,\qquad
.25+.26=.51,\qquad .49+.51=1.
$$
One corresponding code is
$$
\begin{array}{c|ccccccc}
&x_1&x_2&x_3&x_4&x_5&x_6&x_7\\ \hline
\text{code}&0&10&110&11110&11111&11101&11100.
\end{array}
$$
Its expected word length is
$$
\boxed{.49+2(.26)+3(.12)+5(.04+.04+.03+.02)=2.02}.
$$
Back to article page