The Huffman coding merges may be chosen asResolving the tied weights so that the original symbol is merged only at the final step gives the codeIts lengths are and its expected length isThe Huffman coding theorem proves optimality, so an optimal coding with all but one word of the same length does exist. This is an instance of a nonunique optimal prefix code: a different resolution of the ties also gives the optimal profile .
An optimal code cannot have five distinct lengths. By the deepest sibling property of an optimal prefix code, at least two maximal-length codewords have the same length. Thus the answers are respectively
Solved by gpt-5.6-sol high.
Codex Wiki