CS200: Computer Science, Spring 2004
|
Notes: Wednesday 28 January 2004
Schedule Recursive Definitions
- Wednesday, 28 January (needed for PS2): Read SICP, 1.3
- Monday, 2 February: Problem Set 2
- Wednesday, 4 February: Read SICP, 2.1 and 2.2 (through page 127). You don't need to read the example section 2.2.4, but probably don't want to miss the footnote on page 127 about William Barton Rogers, MIT's founder, who left UVa after too many students were rioting outside his pavillion.
- Before 10 March: Read rest of GEB part I (Chapters 2-4 and 6-9, in addition to Chapters 1 and 5 you have already read). There will be no more specific reading assignments from GEB until end of Spring Break (there will be other reading assignments from SICP). By March 10th, you will be expected to have read all of Part I (through page 272) of GEB. I recommend reading about a Chapter a week, but if you prefer to read it all over Spring Break that is fine too.
- Be optimistic.
- Assume you can solve it.
- If you could, how would you solve a bigger problem.
- Think of the simplest version of the problem, something you can already solve. (This is the base case.)
- Combine them to solve the problem.
(define (fibo n) (if (or (= n 1) (= n 2)) 1 ;;; base case (+ (fibo (- n 1)) (fibo (- n 2))))) (define (fast-fibo n) (define (fibo-worker a b count) (if (= count 1) b (fibo-worker (+ a b) a (- count 1)))) (fibo-worker 1 1 n))
How many times is fibo evaluated to evaluate (fibo 10)?
Lists
How many times is fibo-worker evaluated to evaluate (fast-fibo 10)?
What does cons do?
What do car and cdr do?
How could we define cons, car and cdr if Scheme did not have them as primitives?
A quintuple is a pair where ...
Why do we need the special list null?
What is the value of (car (cdr (cons 1 (cons 2 (cons 3 null)))))?
If you're in the penalty area and don't know what to do with the ball,
put it in the net and we'll discuss the options later.
Bob Paisley
cs200-staff@cs.virginia.edu Using these Materials |