We are given the following letters with the respective frequencies:

\begin{equation*}\begin{matrix}a/2 & b/4 & c/7 & d/6 & e/4 & f/5 & g/8 & h/10 & i/3 & j/11\end{matrix}\end{equation*}

For that I have applied the Huffman code and I got the following tree:

enter image description here

Now it is asked for the total weight of the code. How do we calculate that?

Do we maybe use the formula $\displaystyle\sum_{c\in C}f(c)d(c)$ ?

Then we have $$2\cdot 4+3\cdot 4+5\cdot 3+6\cdot 3+7\cdot 3+4\cdot 4+4\cdot 4+8\cdot 3+10\cdot 3+11\cdot 3=193$$ Is that correct?

  • 1
    $\begingroup$ I have never heard of the "total weight" of a prefix code. Ask your professor. $\endgroup$ – Yuval Filmus Jun 5 '20 at 19:30
  • 1
    $\begingroup$ Usually we are interested in the average length of a codeword, and sometimes also in the maximum length of a codeword. $\endgroup$ – Yuval Filmus Jun 5 '20 at 19:31
  • $\begingroup$ Ahh ok! I will ask. The formula I wrote above what does it represent? @YuvalFilmus $\endgroup$ – Mary Star Jun 5 '20 at 19:47
  • $\begingroup$ Formulas are not so important. The two parameters I mentioned are interesting on their own. The formula defining them is less important than their meaning. $\endgroup$ – Yuval Filmus Jun 5 '20 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.