Saint Louis University |
Computer Science A220/P126
|
Dept. of Math & Computer Science |
Topic: Recursion
Related Reading: Ch. 2.5.1 and 4.1
Due:
Monday, 31 January 2005, 1:10pm
Please make sure you adhere to the policies on academic integrity.
Ch 2.5.1 describes a recursive procedure drawTicks(int tickLength). For this problem, we are interested in determining the number of lines of output which are generated by a call drawTicks(L) for a given integer L, including all of the recursive calls it generates.
As a function of L, how many lines of output are
generated?
(Hint: You might wish to try out a few small values by hand)
Give a proof of your result!
Give a C++ implementation of a recursive algorithm for finding the maximum element in an array A of n elements? For the sake of outward appearance, you must support a routine with signature as follows:
int max(int A[], int n)though certainly you may choose to define an additional routine if you wish.
Note: You do not necessarily need to type/execute this code. Doing it on paper is fine. But we ask that you use C++ in describing your answer for the sake of precision.