I was looking at constructing optimal Huffman codes over non-binary alphabets.
This question was asked in Huffman trees for non-binary alphabets?. The solution suggested to use the Huffman coding procedure combining n lowest frequency symbols at a time (as is also suggested by wikipedia). However, This does not seem to be optimal. Say I have 4 alphabets with frequencies,
A --> 0.4
B --> 0.25
C --> 0.2
D --> 0.15
The ternary Huffman code derived here using this would be
A --> 0
B --> 10
C --> 11
D --> 12
However the following code would have shorter expected length:
A --> 0
B --> 1
C --> 20
D --> 21
Am I missing something here?
PS I am posting this as a question because I can not comment on the previous post.