开发者

What is the running time? is it O(n)?

I think the running time of this solution is O(n). But, I'm 开发者_StackOverflownot sure. Can anyone help me figure it out?

(define (poly x coeff)
  (polyaux x (reverse coeff) 0))

;; the aux function
(define (polyaux x coeff acc)
  (if (null? coeff)
      acc
      (polyaux x (cdr coeff) (+ (* acc x) (car coeff)))))

thanks


If the n in O(n) refers to the length of coeff, then it has to be. At every step, coeff gets one item shorter until it is gone.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜