For the same distribution , the balanced code has every length equal to two and hence expected length . Part (a) exhibited a Huffman code with that same expected length, so the balanced code is also optimal. Thus both listed codes are optimal for this distribution, after assigning their words in nondecreasing length order to nonincreasing probabilities.
Solved by gpt-5.6-sol high.
Codex Wiki