As seen in the picture below, I have a list of probabilities and I have to order them from lowest to highest in order to compute the tree, but I am not sure the tree that I have built is correct. As far as I know, if I compute the first two values ($p_1$ and $p_4$) and if their value is higher than $p_7$, then I have to build another subtree of $p_7+p_6$ and so on ? Or maybe I am getting this wrong. Could somebody point me to the right direction on how to build this type of tree correctly with all the rules ?
Asked
Active
Viewed 94 times
0
-
Huffman trees also appeared at this MSE link. – Marko Riedel May 16 '18 at 21:36
1 Answers
0
After combining two of the lowest probabilities (it seems you chose $x_1$ and $x_4$ for this), you should regard their combined probability ($1/8$) as a new element of your set, replacing the two that you combined. So, after you combine $x_6$ with $x_7$, the next step should not combine $x_8$ with $x_2$ but rather combine $x_8$ with the new element (because the probability of the new element, $1/8$, is less than the probability of $x_2$, $3/16$).
Andreas Blass
- 71,833
-
It is still a bit shady what are the rules for the algorithm. Could you point me to a source which explains this properly ? – the_grumpy_cat May 16 '18 at 12:05
-
Is this accurate ? https://i.imgur.com/7ZRbol4.jpg basically after each sum i replace in algorhitm the old values and check again for the smallest 2 and do it again – the_grumpy_cat May 16 '18 at 12:18
-
Yes; you always remove the two numbers you just added and put their sum in place of them. Then iterate. – Andreas Blass May 17 '18 at 00:59
