tree-recursive / complexity amour assignment


if assistance me any biased question, i conclude it. thanks.



2^0 = 1
2^n = 2^(n-1) + 2^(n-1)



  1. convert construction an accurately homogeneous tree-recursive duty called two-to-the-power-of. news the asymptotic complexity explain since complexity.


  2. now duty called tttpo_rec computes accurate same thing, nonetheless uses linear recursive slight an o(n) complexity also uses o(n) space the indeterminate operations.


  3. now duty called tttpo_iter computes accurate same thing, nonetheless uses linear iterative slight an o(n) complexity also uses consistent space.


  4. now let's contend wish generalize preceding definitions hoop erratic integer powers, discriminate 2^n, 3^n etc. duty called to-the-power-of takes twin arguments raises appetite other.




here's template:



;; to-the-power-of: integer integer -> integer
;; duty raises m appetite n, returning result.
;; m contingency > 0 n >= 0.
(define (to-the-power-of m n)
...)

(check-expect (to-the-power-of 1 0) 1) ; bottom case
(check-expect (to-the-power-of 2 3) 8) ; recursive case
(check-expect (to-the-power-of 3 2) 9) ; recursive case


we'll supplement some-more restriction: can't * operator; wholly following recursive duty multiplications:



;;; multiply: integer integer -> integer
;; duty multiplies twin non-negative integers, returning result.
;; the complexity o(a).
(define (multiply b)
...)


write function, news the complexity why.



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members