Computer Science 61A - Fall 1997 - Harvey - Final

# Computer Science 61A - Fall 1997 - Harvey - Final - CS 61A,...

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

CS 61A, Final, Fall 1997 CS 61A, Fall 1997 Final Professor Harvey Problem #1 Given these definitions: (define (square x) (* x x)) (define (inc) (set! count (+ count 1)) count) (define count 5) What is the value of the expression (square (inc)) under applicative order evaluation? What is the value of the same expression under normal order evaluation (without memoization)? Problem #2 True or false: If f is Theta(g) then f + g [the function that maps x to f(x) + g(x)] is Theta(f). Problem #3 Given the tree abstract data type, with constructor make-node and selectors datum and children, consider this procedure: (define (search tree pred) (define (helper tasks) (cond ((null? tasks) #f) ((pred (datum (car tasks))) (datum (car tasks))) (else (helper (append ___________ ___________))))) (helper (list tree))) (a) Fill in the two dashes so that this procedure searches in breadth-first order. (b) Fill in the two dashes so that this procedure searches in depth-first order. file:///C|/Documents%20and%20Settings/Jason%20Raft. ..%20Fall%201997%20-%20Harvey%20-%20Final%20Exam.htm (1 of 8)1/27/2007 6:27:30 PM

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

View Full Document
CS 61A, Final, Fall 1997 Problem #4 Ben Bitdiddle says, "Brian keeps telling us that the idea of data directed programming is much more general that just using get and put. Anything where the data tells the program what to do is data- directed. Therefore, aren't all programs data-directed? The result of calling any procedure depends on what its arguments are." (a) Name a procedure, not generally considered to be data-directed, that provides evidence in favor of Ben's view, and expain why(in no more than two sentences). (b) Name a procedure that does not provide evidence for Ben's view, and explain why(in no more than two sentences). Problem #5 (a) In one or two English sentences, describe something in the real world that would plausibly be implemented in the Adventure game as a class that inherits from both thing and place, and explain why. (b) Dan Ingalls told us that in a real object-oriented language, everything must be an object. Help him out by writing a define-class implementation of pairs (including mutation) that does not depend on Scheme's built-in pair primitives. Problem #6 Draw the environment diagram resulting from the evaluation of the following expressions: (define (kons a b) (lambda (m) (if (eq? m 'kar) a b))) (define p (kons (kons 1 2) 3)) Problem #7 file:///C|/Documents%20and%20Settings/Jason%20Raft. ..%20Fall%201997%20-%20Harvey%20-%20Final%20Exam.htm (2 of 8)1/27/2007 6:27:30 PM
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 05/17/2009 for the course CS 61A taught by Professor Harvey during the Spring '08 term at University of California, Berkeley.

### Page1 / 8

Computer Science 61A - Fall 1997 - Harvey - Final - CS 61A,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online