2.67 Exercise 2.67
To decode the given sample-message, using the given Huffman tree, we can simply call decode with them as arguments:
> (define sample-tree (make-code-tree (make-leaf 'A 4) (make-code-tree (make-leaf 'B 2) (make-code-tree (make-leaf 'D 1) (make-leaf 'C 1))))) > (define sample-message '(0 1 1 0 0 1 0 1 0 1 1 1 0)) > (decode sample-message sample-tree) (mcons 'A (mcons 'D (mcons 'A (mcons 'B (mcons 'B (mcons 'C (mcons 'A)))))))
The message is decoded this:
0 1 1 0 0 1 0 1 0 1 1 1 0 |
A D A B B C A |