Computer Science 61A - Spring 1998 - Fateman - Midterm 1

# Computer Science 61A - Spring 1998 - Fateman - Midterm 1 -...

This preview shows pages 1–2. Sign up to view the full content.

CS 61A Midterm #1, Sp98 CS 61A Spring 1998 Midterm 1 Professors Fateman & Forsyth Question #1 What will Scheme print in response to the following expressions? If it produces an error or runs forever without a result, just say "error". If it is a procedure, say "procedure". Assume no global variables have been defined beforehand except where noted. (word '(+2 3) (+2 3)) ((lambda (x y z) (* 5 y)) 3 4 7) ;from ex. 1.32, p. 61 (accumulate se '(hurrah) (lambda(x) (word 'hip x)) 1 (lambda (x) (1+x)) 3) ((if 3 - *) 32 2) (a b c) (let ((a 5) (* +) (+ *)) a (+ a a)) ((lambda (-) (- 2)) (lambda (*) (+ * 4) )) Question #2 (True or False?) _______ A Ø (log(2n)) algorithm is slower than a Ø (2 log(n)) algorithm _______ For small size inputs knowing the Ø order of an algorithm is more useful than for large inputs _______ If f(x) is Ø (log x), then lim (x => infinity) f(x)/(log x) is zero _______ If f is defined as (define (f x) (* x x x)) then and applicative-order evaluation of (f (g y)) evaluates (g y) more often than a normal -order evaluation _______ Function g below defines a linear recursive process (define (g a b c) (if (> a b) c (+ c ( g (+ a 1) (- b 1) (+ c 1))))) Question #3 Write a linear iterative function

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
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