Ex.2
L=1/4+1/4+2/5+2(1.5)+2(1.5)=1.5
Ex.3
Code tree is incomplete!
We need to combine 3 at last step.
So add DUMMIES
Grouping preference is
so
is a multiple of (D-1) at last stage
Previous case
x=6, x-1=5 not a multiple of D-1=2, so add 1 dummy.
L=.25+.25+2/5+2/10+3/10+3/10+0=1.7
Tree complete!
Extension
Code blocks of k source letters
Ex.
a1 a2 a3 3 source letters
K=3
Clearly,
If n - letter blocks
So for sources with memory, is bounded by H(X) the entropy rate.