For the most part, homework should be your own work. If, however, you get help from a classmate or some other reference for a problem or two, be sure to cite the reference. The citation should appear at the top of your written problem solution.
a0 = 0
a1 = 1
an = an-1 + an-2
(fibonacci n) to compute the
nth Fibonacci number.
(fibonacci n), which
generates an iterative process. Notice that your helper procedure
will need to remember the two Fibonacci numbers as well as
where it is, so it can stop when it's reached n. Be sure
to name your arguments well, and to add a comment explaining what the
arguments are.
(load "~mc27/public/time.scm")Then, try typing
(run-time fibonacci 10)
You'll get a result back from scheme saying something like:
;Time: 7.2142857928385732e-3This means that it took 7.21x10-3 seconds (or .00721 seconds) to compute the 5th Fibonacci number. (Your results will differ.)
Make a single table with these timing results.
(fibonacci n). Choose your scale to make
the iterative version looks good; i.e., the iterative version should
go from the lower left corner of the page to the upper right corner.
The recursive version will be hard to plot clearly on this paper no
matter what the scale, but do your best.
Whenever plotting data in this course, only plot the points; do not connect the points.