SICP Exercise 2.67 use of decode

Exercise 2.67.  Define an encoding tree and a sample message:

(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))


Use the decode procedure to decode the message, and give the result.

SOLUTION

The code and tests are here.

Comments

Popular posts from this blog

SICP Exercise 1.22 search-for-primes

SICP Exercise 3.45 deadlock

SICP Exercise 4.18 a alternative strategy for interpreting internal definitions