zoukankan      html  css  js  c++  java
  • Exercise 1.15 sine

    题目:

      The sine of an angle (specified in radians) can be computed by making use of the approximation sin x  x if x is sufficiently small, and the trigonometric identity. 

    sin(r)=3*sin(r/3)-4*(sin(r/3))^3

    to reduce the size of the argument of sin. (For purposes of this exercise an angle is considered ``sufficiently small'' if its magnitude is not greater than 0.1 radians.) These ideas are incorporated in the following procedures:

    (define (cube x) (* x x x))
    (define (p x) (- (* 3 x) (* 4 (cube x))))
    (define (sine angle)
      (if   (not (> (abs angle) 0.1))
        angle
        (p (sine (/ angle 3.0)))))

    a. How many times is the procedure p applied when (sine 12.15) is evaluated?

    b. What is the order of growth in space and number of steps (as a function of a) used by the process generated by the sine procedure when (sine a) is evaluated?

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------

    函数sine是tree recursive,所以树的高度决定了复杂度。而树的高度为logN。因此,复杂度为 2^logN 即O(N)

  • 相关阅读:
    (CS模式)大学计算机基础考试系统
    四叶草的祝福
    做人的小故事!
    前天晚上回到北京了
    人生活的三种状态
    松口气了!
    Mysql一些基础用法
    云计算随想
    对vector与deque插值与遍历的性能数据
    gdb命令的常用调试选项
  • 原文地址:https://www.cnblogs.com/linghuaichong/p/3978919.html
Copyright © 2011-2022 走看看