notes14 - CS 61A Lecture Notes Week 3 Topic Recursion and...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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.

Ask a homework question - tutors are online