en
Gerald Jay Sussman,Harold Abelson,Julie Sussman

Structure and Interpretation of Computer Programs

Beri tahu saya ketika buku ditambahkan
Untuk membaca buku ini unggah file EPUB atau FB2 ke Bookmate. Bagaimana cara mengunggah buku?
  • Dannimembuat kutipan4 tahun yang lalu
    Fortunately, learning to program is considerably less dangerous than learning sorcery, because the spirits we deal with are conveniently contained in a secure way.
  • Dannimembuat kutipan4 tahun yang lalu
    Exercise 1.18. Using the results of exercises 1.16 and 1.17, devise a procedure that generates an iterative process for multiplying two integers in terms of adding, doubling, and halving and uses a logarithmic number of steps.
  • Dannimembuat kutipan4 tahun yang lalu
    Exercise 1.15. 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

    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?
  • Dannimembuat kutipan4 tahun yang lalu
    Exercise 1.16. Design a procedure that evolves an iterative exponentiation process that uses successive squaring and uses a logarithmic number of steps, as does fast-expt. (Hint: Using the observation that (bn/2)2 = (b2)n/2, keep, along with the exponent n and the base b, an additional state variable a, and define the state transformation in such a way that the product a bn is unchanged from state to state. At the beginning of the process a is taken to be 1, and the answer is given by the value of a at the end of the process. In general, the technique of defining an invariant quantity that remains unchanged from state to state is a powerful way to think about the design of iterative algorithms.)
  • Dannimembuat kutipan4 tahun yang lalu
    Exercise 1.17. The exponentiation algorithms in this section are based on performing exponentiation by means of repeated multiplication. In a similar way, one can perform integer multiplication by means of repeated addition. The following multiplication procedure (in which it is assumed that our language can only add, not multiply) is analogous to the expt procedure:
    (define (* a b) (if (= b 0) 0 (+ a (* a (- b 1)))))
    This algorithm takes a number of steps that is linear in b. Now suppose we include, together with addition, operations double, which doubles an integer, and halve, which divides an (even) integer by 2. Using these, design a multiplication procedure analogous to fast-expt that uses a logarithmic number of steps.
  • Dannimembuat kutipan4 tahun yang lalu
    Exercise 1.13. Prove that Fib(n) is the closest integer to φn/√5, where φ = (1 + √5)/2. Hint: Let ψ = (1 - √5)/2. Use induction and the definition of the Fibonacci numbers (see section 1.2.2) to prove that Fib(n) = (φn - ψn)/√5.
  • Dannimembuat kutipan4 tahun yang lalu
    Exercise 1.14. Draw the tree illustrating the process generated by the count-change procedure of section 1.2.2 in making change for 11 cents. What are the orders of growth of the space and number of steps used by this process as the amount to be changed increases?
  • Dannimembuat kutipan4 tahun yang lalu
    Exercise 1.12. The following pattern of numbers is called Pascal's triangle.

    The numbers at the edge of the triangle are all 1, and each number inside the triangle is the sum of the two numbers above it.35 Write a procedure that computes elements of Pascal's triangle by means of a recursive process.
  • Dannimembuat kutipan4 tahun yang lalu
    Exercise 1.11. A function f is defined by the rule that f(n) = n if n<3 and f(n) = f(n - 1) + 2f(n - 2) + 3f(n - 3) if n> 3. Write a procedure that computes f by means of a recursive process. Write a procedure that computes f by means of an iterative process.
  • Dannimembuat kutipan4 tahun yang lalu
    Exercise 1.10. The following procedure computes a mathematical function called Ackermann's function.
    (define (A x y) (cond ((= y 0) 0) ((= x 0) (* 2 y)) ((= y 1) 2) (else (A (- x 1) (A x (- y 1))))))
fb2epub
Seret dan letakkan file Anda (maksimal 5 sekaligus)