Mini-project about 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 2 from Week 11 in detail.

Question 1

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

Question 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.)

Question 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 fold_binary_tree (which is defined in the accompanying file).
  4. Verify that your implementation passes the unit tests.

Question 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 fold_binary_tree (which is defined in the accompanying file).
  4. Verify that your implementation passes the unit tests.

Resources

Version

Fixed a typo in the error message in the accompanying .ml file [19 Apr 2020]

Spelled out the questions and added the resource file [05 Apr 2020]

Created [04 Apr 2020]