cs61a_sp08_mt1_02 - (else (foo (- n 2))))) _______ _______...

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

View Full Document Right Arrow Icon
Question 3 (3 points): (define (trick x y) (* y y)) What is the result of (trick (/ 1 0) 5) a. In normal order b. In applicative order (define (inc x) (+ x 1)) c. True or False: In evaluating (inc (inc (+ 3 2))) , + gets called more in normal than in applicative order ________True _______False Question 4 (4 points): (a) what is the order of growth in time of foo below, in terms of n , its argument? (Hint: if n is odd, so is n - 2.) also, does foo generate an iterative or a recursive process? (define (foo n) (cond ((= n 1) 1) ((even? N) (foo (+ n 1)))
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (else (foo (- n 2))))) _______ _______ ( 2 ) ________ (2 n ) ______Not enough information to know _______Iterative ______Recursive (b) What is the order of growth in time of count-to below? Note: using se with a sentence as its first argument and a word as its second argument takes time proportional to the length of the sentence. (define (count-to N) (if (= N 1) (1) (se (count-to (-N 1)) N))) _______ _______ ( 2 ) ________ (2 n ) ______Not enough information to know _______Iterative ______Recursive...
View Full Document

Ask a homework question - tutors are online