MHB How Do You Calculate the Total Weight of a Huffman Code?

  • Thread starter Thread starter mathmari
  • Start date Start date
  • Tags Tags
    Code Weight
mathmari
Gold Member
MHB
Messages
4,984
Reaction score
7
Hey! 😊

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:

Huffman.JPG
Now it is asked for the total weight of the code. How do we calculate that? :unsure:
 
Physics news on Phys.org
mathmari said:
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:

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

The total weight would be the weighted path length from the root.
The objective of the algorithm is to minimize the total weight, implying that compression is optimal. 🧐

Put differently, it is the length of the resulting code for each symbol multiplied by its frequency and then summed together.
So the contribution of $a$ is $4\times 2=8$, since $a$ is encoded by $0000$, which has length $4$ and it occurs $2$ times. 🤔

I think your tree is not optimal though. I found a different tree with a slightly lower total weight. (Sweating)
 
Namaste & G'day Postulate: A strongly-knit team wins on average over a less knit one Fundamentals: - Two teams face off with 4 players each - A polo team consists of players that each have assigned to them a measure of their ability (called a "Handicap" - 10 is highest, -2 lowest) I attempted to measure close-knitness of a team in terms of standard deviation (SD) of handicaps of the players. Failure: It turns out that, more often than, a team with a higher SD wins. In my language, that...
Hi all, I've been a roulette player for more than 10 years (although I took time off here and there) and it's only now that I'm trying to understand the physics of the game. Basically my strategy in roulette is to divide the wheel roughly into two halves (let's call them A and B). My theory is that in roulette there will invariably be variance. In other words, if A comes up 5 times in a row, B will be due to come up soon. However I have been proven wrong many times, and I have seen some...

Similar threads

Replies
18
Views
1K
Replies
1
Views
990
Replies
4
Views
4K
Replies
8
Views
944
Replies
6
Views
2K
Replies
1
Views
1K
Replies
17
Views
1K
Replies
9
Views
2K
Back
Top