CS 2334 - Programming Structures and Abstractions

Honors Assignment 4 — Comparison Four

Due Friday, December 6, 2013, 1:30pm

Note: Due to time constraints, "Collections" has been dropped from our list of topics and Recursion is now the topic of Honors Assignment 4 rather than Honors Assignment 5. There will be no honors assignments 5 or 6.

As discussed in class, recursion is an elegant and powerful algorithm design pattern that matches well with many types of structured information, such as mathematical equations and hierarchical directories of computer files. However, recursion can also be terribly inefficient, as exemplified by the naive Fibonacci function shown in class. In some cases, an iterative approach to the same problem can be much more efficient than a recursive approach, even if the iterative approach does not match as nicely with the concept underlying the structured information.

This assignment explores an example of this design trade-off between recursion and iteration.

The assignment.

Consider again the naive Fibonacci function we covered in class, as well as the two iterative Fibonacci functions we covered (one that stores the values in an array and one that stores values in two temporary variables). Write a paper comparing these three functions. In your paper, be sure to compare the following:

You may cover these points in any order that clearly conveys the information required.

Your comparison paper should be approximately three to five pages in length (roughly 80 characters per line, 50 lines per page). Note that this is a guideline range. Values somewhat outside this range are acceptable. However, if you go much over five pages, I may take off points for being excessively verbose. This page range does not include figures used in your explanations, which are encouraged and may take up any amount of space.

What to turn in.

Turn in an electronic copy of this document as a PDF file by submitting it to the appropriate droxbox in D2L and a paper copy of this document at or prior to the start of the class period on the due date.