I understand how to create Huffmann trees when the frequencies are different to each other but how would I draw this huffmann tree if few of the frequencies are the same:
simple explanation of the Huffmann trees is found here
The data of the Huffmann tree I am trying to create:
Letter Frequency
A 15%
B 15%
C 10%
D 10%
E 30%
F 20%
Now I start with the two lowest frequencies which are for Letter C
and D
.
/ \
C D
But what would be the next step? because we have A
and B
with the same frequencies so which one do we choose? If we choose one of them, then how will the structure look when the second one is chosen?
If I choose B
then it will look like this (unless I am wrong)
.
/ \
B .
/ \
C D
What about after this step???
These can be coded in Java and C as well and I am trying to figure out how these work first before implementing them.
EDIT
My tree looks like this:
___________|_________________
/\ |
/ \ |
F E |
/ \ |
/ \ |
B A /\
/ \
C D
Also got an example from online