(load "C:\\Documents and Settings\\mccoy\\My Documents\\CISC280-04s\\Scheme-Test-Files\\some-math-functions.scm") ; computes b to the n -- recursive process ; O(n) in both time and space (define (exp1 b n) (if (= n 0) 1 (* b (exp1 b (dec n))))) ; computes b to the n -- iterative process ; O(n) in time, but O(1) in space (constant) (define (exp2 b n) (exp-iter1 1 b n)) ; product contains intermediate value ; product = b^(n - ctr) (define (exp-iter1 product b ctr) (if (= ctr 0) product (exp-iter1 (* product b) b (dec ctr)))) ; computes b to the n -- recursive process ; more efficient calculation ; O(log(n)) in both time and space (define (exp3 b n) (cond ((= n 1) b) ((= n 2) (* b b)) ((even? n) (square (exp3 b (/ n 2)))) (else (* b (exp3 b (dec n))))))