Middle Earth

sicp-exercise-1.14-1.15

Exercise 1.14

‘Count-change generates a tree-recursion process.’

‘In general, the number of steps required by a tree-recursive process will
be proportional to the number of nodes in the tree, while the space required
will be proportional to the maxinum depth of the tree.’

The depth is amount/value-of-smallest-coin.
The number of nodes is FIXME

Exercise 1.15

a.

(sine 12.15)
(p (sine 4.05))
(p (p (sine 1.35)))
(p (p (p (sine 0.45))))
(p (p (p (p (sine 0.15)))))
(p (p (p (p (p (sine 0.05))))))
(p (p (p (p (p 0.05)))))


So, when (sine 12.15) is evaluated, p is applied five times.

b.

When (sine a) is evaluated, the number of times p is applied is log(a/0.1)
based on 3, i.e. int( ln(a/0.1) / ln(3) ). So the order of growth can be
written as theta of log(a).

The order of growth in space is the same. (right?)

Comments