previous | index | next

Logarithmic Iteration

We can write power iteratively to gain Θ(1) space efficiency.

This is essentially Exercise 4.4 (assignment 2).

Linear iteration can be converted to logarithmic iteration by recognizing that if e is even, then

a × be = a × (b2)e/2
(define power-product
  (lambda (a b e)
    (if (= e 0)
        a
        (if (even? e)
            _____________________
            _____________________))))

previous | index | next