| Symbol | frequency |
| a | .3 |
| b | .24 |
| c | .2 |
| d | .16 |
| e | .1 |
First combine d and e yielding a cumulative Frequency of .26
Next combine b and c yielding a cumulative Frequency of .44
Next combine a and (d e) yielding a cumulative Frequency of .56
Next combine (a d e) and (b c) yielding a cumulative Frequency of 1.00
This yoelds the tree in list notation
(1.00 (.56 (.3=a) (.26 (.16=d)(.1=e)))
(.44 (.24=b) (.2=c))
)
And then using the convention of 0 to the left 1 to the right
Symbol Huffman-code
a 00
b 10
c 11
d 010
e 011
There are other solutions based on the convention for labeling left and right
but all of them will have the lengths of the ones above.
S -> NP VP NP -> art ADJL noun | art noun ADJL -> adj ADJL | adj VP -> verb NP | verb
father(sam, bill) father(ben, bill) father(bill, joe) father(mary, joe) mother(ralph, mary) parent(X,P) :- father(X,P). parent(X,P) :- mother(X,P). sibling(X,Y) :- parent(X,P), parent(Y,P).