previous | index | next

Linear Recursion

power generates a recursive process because:

Q: How many times is power called (in terms of e)?

A: e times

Since most of the computing cost in power is bound up in the recursive call, the time it takes to compute is Θ(e).

This is an example of linear recursion, since the number of recursive calls is linear in the exponent.

Q: What is the maximum number of waiting multiplications (in terms of e)?

A: e multiplications

Each waiting multiplication requires that Scheme allocate extra memory, so the amount of memory required by power is also Θ(e).


previous | index | next