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

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

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 the argument, so we do N altogether.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern