Assignment 2
CS 270/680 Mathematical Foundations of Computer Science
Instructor: Jeremy Johnson
Due date: (Beginning of class on Oct. 12)
- Exercise 2.5.3 from the text
- Exercise 2.7.7 from the text
- Exercise 2.9.4(a) from the text
- In this question you will investigate the a recursive
program to simultaneously compute the minimum and maximum
element in a vector of integers.
- Write a main program that calls the function
minmax
and counts the number of comparisons used when
called with a vector of size n (you can use the vector
whose elements are 0,1,...,n-1).
- Use the program you wrote to determine the number of
comparisons used for vectors of size 2^k, for k=1,...,10.
- Write a recurrence relation for the number comparisons
used by minmax for vectors of size 2^k. Use the recurrence
to compute the values for size 2^k, for k=1,...,10 and compare
to those obtained from your program.
- Use repeated substitution to convert the recurrence relation to
a sum and find a closed form solution for the sum (you will have
seen the sum before).
Graduate Student Problem
- Exercise 3.11.11 from the text
How to submit
Students should submit their solution electronically. Use a word processor
(e.g. word with the equation editor or latex) to create your solution and submit
either 1) a text file, 2) a word document, or 3) a pdf file. Alternatively, you
can submit a pdf file containing a scan of a handwritten solution. You should also
submit the program you wrote to determine the number of comparisons used by
minmax (make sure you have a readme file explaining how to compile and use the
program). You should submit your assignment using WebCT. Bring
a paper copy of your homework to the class meeting when it is due. WebCT
will be set up to accept assignments on Thursday.