The Huffman algorithm pairs the sub-trees by weight. As long as there are more than one sub-tree, pairs the lightest two into one sub-tree. I chose to have the lightest branches on the left (bit 0).
49 For a file containing: 27 A
/\ 15 B
22 A 3 C
/\ 1 D
7 B 1 E
/\ 1 F
C 4 1 G
/\
2 2 the resulting tree is (with the weight of each
/\ /\ sub-tree noted at its root) drawn on the left.
D EF G
####
49 For alphabet and: 27 A
/\ and weights as so: 15 B
22 A 3 C
/\ 1 D
7 B 1 E
/\ 1 F
4 C 1 G
/\
2 2 Ordered so that the most frequent
/\ /\ have the least 0's in their path
D EF G
A=1 C=001 E=00001 G=00011
B=01 D=00000 F=00010
##
##
a 27 1
b 15 01
c 3 000
d 1 00100
e 1 00101
f 1 00110
g 1 00111
##
##
a 27 1
b 15 01
c 3 001
d 1 00000
e 1 00001
f 1 00010
g 1 00011