Mini-project: Multiplying integers in a tree using an accumulator

The goal of this mini-project is to spell out how to multiply integers in a tree using an accumulator by solving Exercise 21 in detail.

Task 1

Explain, in your own words, the structure and the rationale of the unit-test function in the accompanying file.

Task 2

Expand the unit-test function so that it does not just test the candidate function on one random binary tree of integers, but on a given number of random binary trees of integers.

(Hint: use repeat as defined in the accompanying file.)

Task 3

  1. Implement one more version of the multiplication function over binary trees, mult_v7, using an accumulator and no exception.
  2. Verify that your implementation passes the unit tests.
  3. Express your implementation using binary_tree_fold (which is defined in the accompanying file).
  4. Verify that your implementation passes the unit tests.

Task 4

  1. Implement one more version of the multiplication function over binary trees, mult_v8, using an accumulator and an exception.
  2. Verify that your implementation passes the unit tests.
  3. Express your implementation using binary_tree_fold (which is defined in the accompanying file).
  4. Verify that your implementation passes the unit tests.

Resources

Version

Created [10 Jan 2023]