= Solution
For an <even integer> $m\geq2$, \b[merge the two least weights once, then repeatedly merge three least weights] until only the <tree root> remains. The initial binary merge leaves an <odd number> of weighted objects, so the preceding algorithm applies. The initial merged <tree parent> has two <tree children>; subsequent <tree parents> have three. Equivalently, add one zero-weight dummy symbol, run the odd-leaf <ternary Huffman coding> algorithm, and remove its <codeword> afterwards. The dummy contributes nothing to <expected codeword length>.
Here the first merge joins the two weights $1/8$, producing $1/4$. The three remaining weights are $1/2,1/4,1/4$, and merge directly into the <tree root>. Assigning the first two <tree root> branches to the original symbols of weights $1/2$ and $1/4$ gives
$$
\boxed{c(1)=0,\quad c(2)=1,\quad c(3)=20,\quad c(4)=21,\qquad L(c)=\frac54\ \text{trits}.}
$$
The merge-weight check gives $1/4+1=5/4$ as well. For $m=2$, the first merge is already the <tree root>; for $m=1$, outside this case with an <even number> of symbols, the usual temporary reduced-problem convention would permit an <empty word>.
Back to article page