Guided Practice 6.2: A Different Kind of Tree

Consider a data structure of trees that have leaves with numbers in them, and two kinds of interior nodes: one kind with two sons and the other kind with three sons. Here's an example:

example tree

These trees are similar, but not identical to what are usually called 2-3 trees.

  1. Write a data definition for these trees, including a template and a halting measure.
  2. Write leaf-max for these trees.
  3. Write a function double-all that takes one of these trees and returns a tree of the same shape in which all the leaves are doubled. For example, double-all applied to the tree above should return the tree
  4. example tree

[ANSWER]

(Remember, you won't get anything about of this exercise unless you actually write the code and test it.)

Last modified: Mon Sep 5 22:41:27 Eastern Daylight Time 2016