# Optimal Coding Scheme for given Weights

I'm having trouble with this homework problem. Do I create the tree by beginning with each weight being a leaf? Then combining the lowest weighted leaves, and their parent becomes the sum of their weight?

I got 85 as my answer for (b) but I'm not sure if this is the correct process

Consider the weights: 10, 12, 13, 16, 17, 17.

(a) Construct an optimal coding scheme for the weights given by using a tree.

(b) What is the total weight of the tree you found in part (a)?

-
Yes, you first combine $10+12=22$, then $13+16=29$, then $17+17=34$, then $22+29=51$, finally $51+34=85$ (thus your answer for b).
If we always represent the first choice with 0 and the second with 1, the respective code words are $$000,001, 010, 011, 10, 11.$$ I'm not sure if part b isn't rather referring to the weighted code word length, that is $\frac{3\cdot 10+3\cdot 12+3\cdot 13+3\cdot 16+2\cdot 17+2\cdot 17}{10+12+13+16+17+17}$.