Similar questions 3 more →
Greedy Algorithms

Answer & solution
Official answer: 225.0
Our answer: 225
1. Huffman coding repeatedly merges the two smallest current weights. Merge T and R:0.08+0.17=0.25. Next merge S and P:0.19+0.22=0.41. The remaining weights are 0.25,0.34,0.41; merge 0.25+0.34=0.59, then 0.41+0.59=1.
2. The resulting depths are 2 for P,Q,S and 3 for R,T. One valid code assignment is S=00,P=01,T=100,R=101,Q=11; swapping branch labels changes codewords but not lengths.
3. Expected bits per symbol are 2(0.22+0.34+0.19)+3(0.17+0.08)=1.5+0.75=2.25. Equivalently sum the merge weights 0.25+0.41+0.59+1=2.25. For 100 symbols the expectation is 225 bits, excluding codebook/container overhead. It is an expectation, not a guarantee for every possible 100-symbol sequence.