On this page:
Readings
Supplemental Materials
Pre-lecture
Goals
In-class
Homework

Module 07

Last updated: Thu, 12 Feb 2015 10:47:33 -0500

Readings
Supplemental Materials
Pre-lecture
  1. Read the Readings and Supplemental Materials.

Goals
In-class

This exercise demonstrates that accumulators are useful not only with lists.
Below is a data definition for a binary tree. Complete the rest of the Data Design steps.
Then implement the function bt-depths. Make sure to satisfy all the requirements for Accumulators if you use one (or more).
; A BinaryTreeOf<X> (BTreeOf<X>) is one of:
; - X
; - (make-tree BTreeOf<X> BTreeOf<X>)
; Represents a binary tree where the X elements are stored at the leaves.
 
; A Depth is a Natural
; Representing the number of steps from the root of a tree to a node.
 
; bt-depths : BTreeOf<X> -> BTreeOf<Depth>
; Replaces the value at each node in bt with its depth.
; The root node has depth 0.
(define (bt-depths bt) ...)

Homework

Problem Set 07