sicp-solutions/chapter-2/ex-2.71.txt
2025-09-11 13:00:45 +02:00

36 lines
849 B
Text

(A 1), (B 2), (C 4), ...
Tree sketch (n=5):
*
/ \
(E 16) *
/ \
(D 8) *
/ \
(C 4) *
/ \
(B 2) (A 1)
tree sketch (n=10):
*
/ \
(J 512) *
/ \
(I 256) *
/ \
(H 128) *
/ \
(G 64) *
/ \
(F 32) *
/ \
(E 16) *
/ \
(D 8) *
/ \
(C 4) *
/ \
(B 2) (A 1)
The most frequent symbol always requires exactly 1 bit.
The two least frequent symbols will always require exactly n-1 bits.