SICP 연습문제 1.11 풀이

Universal Machine/SICP | 2008/12/28 21:22 | The Doctor
이 문서는 Structure and Interpretation of Computer, by Abelson, Sussman, and Sussman의 라이센스 이용허가규약 저작자표시-비영리에 따라 제작된 문서입니다. 

혼자 공부하면서 풀어본 것입니다. 그런만큼 오류가 많을 것이라 생각합니다. 문제 있는 부분은 알려주시면 고맙겠습니다.




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.


펼쳐두기..




SICP 연습문제 1.10 풀이

분류없음 | 2008/12/20 13:49 | The Doctor
이 문서는 Structure and Interpretation of Computer, by Abelson, Sussman, and Sussman의 라이센스 이용허가규약 저작자표시-비영리에 따라 제작된 문서입니다.

혼자 공부하면서 풀어본 것입니다. 그런만큼 오류가 많을 것이라 생각합니다. 문제 있는 부분은 알려주시면 고맙겠습니다.

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))))))

What are the values of the following expressions?


(A 1 10)


펼쳐두기..


(A 2 4)

펼쳐두기..


(A 3 3)

펼쳐두기..



Consider the following procedures, where A is the procedure defined above:

(define (f n) (A 0 n))

(define (g n) (A 1 n))

(define (h n) (A 2 n))

(define (k n) (* 5 n n))

Give concise mathematical definitions for the functions computed by the procedures fg, and h for positive integer values of n. For example, (k n) computes 5n2.




펼쳐두기..





참고사항

Ackermann function : wikipedia 애커만 함수 항목

SICP 연습문제 1.9 풀이

Universal Machine/SICP | 2008/12/18 21:47 | The Doctor
이 문서는 Structure and Interpretation of Computer, by Abelson, Sussman, and Sussman의 라이센스 이용허가규약 저작자표시-비영리에 따라 제작된 문서입니다. 

혼자 공부하면서 풀어본 것입니다. 그런만큼 틀린게 꽤 많을 것입니다. 문제 있는 부분은 알려주시면 고맙겠습니다.


Exercise 1.9.  Each of the following two procedures defines a method for adding two positive integers in terms of the procedures inc, which increments its argument by 1, and dec, which decrements its argument by 1.

(define (+ a b)
  (if (= a 0)
      b
      (inc (+ (dec a) b))))

(define (+ a b)
  (if (= a 0)
      b
      (+ (dec a) (inc b))))

Using the substitution model, illustrate the process generated by each procedure in evaluating (+ 4 5). Are these processes iterative or recursive?





펼쳐두기..

이 문서는 Structure and Interpretation of Computer, by Abelson, Sussman, and Sussman의 라이센스 이용허가규약 저작자표시-비영리에 따라 제작된 문서입니다. 

혼자 공부하면서 풀어본 것입니다. 틀린게 꽤 많을지도 모르겠습니다. 문제 있는 부분은 알려주시면 고맙겠습니다.

Exercise 1.7.  The good-enough? test used in computing square roots will not be very effective for finding the square roots of very small numbers. Also, in real computers, arithmetic operations are almost always performed with limited precision. This makes our test inadequate for very large numbers. Explain these statements, with examples showing how the test fails for small and large numbers. An alternative strategy for implementing good-enough? is to watch how guess changes from one iteration to the next and to stop when the change is a very small fraction of the guess. Design a square-root procedure that uses this kind of end test. Does this work better for small and large numbers?


펼쳐두기..






Exercise 1.8.  Newton's method for cube roots is based on the fact that if y is an approximation to the cube root of x, then a better approximation is given by the value

Use this formula to implement a cube-root procedure analogous to the square-root procedure. (In section 1.3.4 we will see how to implement Newton's method in general as an abstraction of these square-root and cube-root procedures.)



펼쳐두기..




소셜 네트워크 서비스에 필요한 두 가지 작업은 첫번째가 노드 구축이며, 두번째가 노드의 연결이다.

그런데 이런 서비스를 구축하는데 있어 대부분의 서비스는 노드 구축에 치중하게 된다.
왜냐하면 당연하게도 노드가 없이 연결이 이뤄질 수 없기 때문이다.

그러나 실제의 서비스를 성공시키기 위한 핵심은 노드 자체보다는 연결을 어떻게 시켜주느냐에 있다.
왜냐하면 노드 자체를 통해 연결이 이뤄지는 것은 이미 우리나라에서는 싸이월드가 어찌되었던 간에 1위이며, 다른 나라에도 이미 1위 사이트가 존재하기 때문이다. 1위 네트워크는 '어쨌든' 굉장히 무너지기 어렵다.

다만 나는 여기서 새로운 노드 집합 구축 없이 기존의 것을 노드로 삼는 소셜 네트워크 서비스가 가능하지 않을까?" 라는 생각에 이르렀었고, 한두 가지 모델을 떠올렸었다.