Name:______________________________________            Page 4

Problem 3. The first two parts of this problem are concerned with the
representation of environments given in the handout.  The remaining
parts are concerned with a modification suggested by Ben Bitdiddle.

A. In the space provided below, draw a box-and-pointer diagram of the
value returned by the EXTEND-ENVIRONMENT procedure given in the
handout, during evaluation of the following expression in the global
environment:

          ((lambda (x y) (+ x (* x y))) 3 4)

You need not draw the structure of the global environment -- a pointer
to a label by that name will be sufficient.

Your answer:











B. In the space provided below, complete the definition of the
procedure COST-OF-ENVIRONMENT.  When given an environment constructed
by the interpreter in the handout, COST-OF-ENVIRONMENT should return
the number of CONS cells that had to be made to construct that
environment (including all enclosing environments).  Be careful: Do
not count any cells that may have been made to construct the values of
the variables bound in the environment.

(define (cost-of-environment env)







