I drew the diagram leaving the letters in the order they came, just to show you
can do it. Here it is, followed by the explanation:
The least common letters are B and G, so connect them first to make BG with probability
0.04. Then the least common letters are BG and H, so connect them to make BGH with
probability 0.10. Now the least common letters are F and BGH, so connect them to make
BFGH with probability 0.20. Now the least common letters are A and BFGH, so connect them
to make ABFGH with probability 0.38. At this point the least common letters are C and D,
so connect them to make CD with probability 0.30. Then the least common letters are CD and
E so connect them to make CDE with probability 0.62. Finally connect ABFGH with CDE to
make ABCDEFGH with probability 1.0.
Next, put 0 / 1 labels on the branches of each connection as shown. Then you can read off
the code for each letter by the sequence of 0's and 1's you pass to get from the root ABCDEFGH
of the tree to the letter at the other end:
|Total (expected length):||2.82|
The expected letter length is 2.82, which is less than the 3.0 bits per letter that
would be required by a fixed length code - it's about 6% better (3-2.82)/3.