AP CS Quiz

1. Draw the box and pointer diagrams for:

A. (define x (list 1 2))

B. (define y (cons 3 x))

C. (define z (list x y))

2. (reduce + '(1 2 3 4)) should work by first adding 1 to 2, getting 3, and reinserting the 3 so that the call is rewritten as (reduce + '(3 3 4)). Once this process has been repeated to the point where there is one element left in the list, the function call would be (reduce + '(10)) at which point reduce would return the 10.

Write reduce.