Exercise 1.19

Posted on Friday, September 28th, 2007

So I never really expected this course to be so much about math – but I am beginning to see the importance of math more and more. It makes me wish that I had [...]

continue reading

Exercise 1.18

Posted on Tuesday, September 25th, 2007

Here are the rules for the Russian peasant method:

Write each number at the head of a column.
Double the number in the first column, and halve the number in the second column.
If the number in the [...]

continue reading

Exercise 1.17

Posted on Saturday, September 22nd, 2007

(define (halve x) (/ x 2))

(define (double x) (+ x x))

(define (even? x)
(= (remainder x 2) 0))

(define (* a b)
(write b)
(cond ((= b 0) 0)
[...]

continue reading

Exercise 1.16

Posted on Thursday, September 13th, 2007

(define (square x) (* x x))

(define (even? n)
(= (remainder n 2) 0))

(define (exp b n)
(exp-iter b n 1))

(define (exp-iter b n a)
(cond ((= n 1) a)
[...]

continue reading

Exercise 1.15

Posted on Thursday, September 13th, 2007

a. The procedure p is applied 5 times.

(sine 12.15))
(p (sine 4.05)))

(p (p (sine 1.35))))

(p (p (p (sine .45)))))

(p (p (p (p (sine .15))))))

(p (p (p (p (p (sine .05)))))))
b. So I’m really unclear about [...]

continue reading

Exercise 1.14

Posted on Wednesday, September 12th, 2007

The number of steps or space required is directly proportional to n since there is always the case of n pennies. So Θ(n).  The time would be exponentially related to n since you have [...]

continue reading

Exercise 1.13

Posted on Wednesday, September 12th, 2007

Ok, so I’m not taking this class to learn about math proofs so instead I wrote a program to test out the equations:

(define (fib n)
(cond ((= n 0) 0)
[...]

continue reading

Exercise 1.12

Posted on Tuesday, September 11th, 2007

(define (p y x)
(cond ((= y x) 1)
((= y 1) 1)
((= x 1) 1)
[...]

continue reading

Exercise 1.11

Posted on Tuesday, September 11th, 2007

; f(n) = n if n < 3
; f(n) = f(n-1) + 2f(n-2) + 3f(n-3) if n >= 3

; recursive
(define(f n)
(if (< n 3)
n
[...]

continue reading

Exercise 1.10

Posted on Tuesday, September 11th, 2007

(A 1 10)(A (0 (A 1 9)))

(A 0 (A 0 (A 1 8)))

(A 0 (A 0 (A 0 (A 1 7))))

(A 0 (A 0 (A 0 (A 0 (A 1 6)))))

(A 0 (A 0 (A [...]

continue reading
Older Entries