Unformatted text preview: CS 61A Lecture Notes Week 3 Topic: Recursion and iteration Reading: Abelson & Sussman, Section 1.2 through 1.2.4 (pages 31–72) This week is about efficiency. Mostly in 61A we don’t care about that; it becomes a focus of attention in 61B. In 61A we’re happy if you can get a program working at all, except for this week, when we introduce ideas that will be more important to you later. We want to know about the efficiency of algorithms, not of computer hardware. So instead of measuring runtime in microseconds or whatever, we ask about the number of times some primitive (fixed-time) operation is performed. Example: ;;;;; In file cs61a/lectures/1.2/growth.scm (define (square x) (* x x)) (define (squares sent) (if (empty? sent) ’() (se (square (first sent)) (squares (bf sent)) ))) To estimate the efficiency of this algorithm, we can ask, “if the argument has N numbers in it, how many multiplications do we perform?” The answer is that we do one multiplication for each number in themultiplications do we perform?...
View Full Document
This note was uploaded on 02/17/2010 for the course COMPUTER S 26275 taught by Professor Harvey,b during the Spring '10 term at Berkeley.
- Spring '10