CSCI 1312 (Introduction to Programming for Engineering), Fall 2018:
Homework 7 Solution (Programming Problems)

  1. (20 points)

    Refer to assignment for description of problem.

    Solution: Here are two solutions, the first with just the required part and the second with the extra-credit part too:

    rands-1.c.

    rands-2.c.

  2. (20 points)

    Refer to assignment for description of problem.

    Solution: Here are two solutions, the first making the array for memoization a global variable and the second making it a parameter to the recursive-with-memoization version of the Fibonacci function:

    The first method is simpler in a way, but strictly speaking requires one to consider what to do if the array is not big enough; the second one is not quite as simple except that one can make the array just big enough.



Berna Massingill
2018-11-30