next up previous
Next: About this document

MASSACHVSETTS INSTITVTE OF TECHNOLOGY
Department of Electrical Engineering and Computer Science
6.001---Structure and Interpretation of Computer Programs
Spring Semester, 1999

Recitation -- Wednesday, February 24

1. Abstracting Common Patterns

2. List Warm-Up

Write the following procedures using map, filter, and accumulate (no recursion!).

3. Depth of a Tree

Write a function depth that takes a tree and returns the maximum depth of the tree. Note that this is equivalent to the maximum number of parenthesis open at any given time when scheme prints the tree. For example,

Now write depth using map and accumulate...

4. Deep Reverse

So far, we've been working on lists, while we've ignored the elements of the list. What does the following return?
(reverse (list 1 (list 2 3) (list 4 5 6)))

Write a function deep-reverse that when called on the above tree will reverse all the elements. (deep-reverse (list 1 (list 2 3) (list 4 5 6))) ==> ((6 5 4) (3 2) 1)

Now write deep-reverse using map...

6. Sieve of Eratosthenes

Let's walk through the process of the sieve of Eratosthenes one more time..





next up previous
Next: About this document



Michael E. Leventon
Fri Mar 19 17:48:24 EST 1999