**Directions:** Each of the first two questions
is a statement that may be true
or false. Please **state whether it is true or false** -- you will
get five points for a correct boolean answer and there is no penalty
for a wrong guess. Then **justify your answer** -- the remaining
points will depend on the quality and validity of your justification.

**Question 1 (10):**(true/false with justification) If f(n) and g(n) are both increasing functions, each of which is in Ω(h(n)), then the function f(n) +g(n) is also in Ω(h(n)).**Question 2 (10):**(true/false with justification) Let T(n) be a nondecreasing function such that wheneve n = 2^{k}, T(n) = 2^{n}. (Thus for these n's, T(n) = 2^{2k}.) Then T(n) is in Θ(2^{n}).**Question 3 (20):**Solve the following recurrence exactly and prove by induction that your answer is correct:T(n) = 2T(n-1) - T(n-2) for n ≥ 2; T(0) = 3; T(1) = 3

**Question 4 (40):**Let A be an array of n Comparables, no two of them equal. The*median*of A is defined to be the element that is greater than exactly n/2 other elements. (Here "n/2" means the floor of n/2 as in Java integer division.)- (a,20) Describe an algorithm to determine the median by brute
force, according to the definition above. This algorithm should have
worst-case running time of Θ(n
^{2}) -- if it is faster than that, then it is not "brute-force" but you may use it for part (c). Pseudocode is fine if it is perfectly clear what your algorithm does. - (b,10) What is the average-case running time of your algorithm, assuming that the median is equally likely to be in any position of A? Justify your answer.
- (c,10) Briefly indicate a method to find the median that is
asymptotically faster than Θ(n
^{2}) (that is, its running time is not Ω(n^{2})). Justify your answer.

- (a,20) Describe an algorithm to determine the median by brute
force, according to the definition above. This algorithm should have
worst-case running time of Θ(n
**Question 5 (20):**Consider a version of Quicksort that uses the brute-force median algorithm of Question 4 to find its pivot. Write a recurrence for the running time of this algorithm and solve it (in Θ terms) using the Master Theorem.

Last modified 27 September 2003