# CS 5114 Homework 3 (Spring 2008)

Assigned on Wednesday, February 20, 2008. Hardcopy due at the beginning of class on Wednesday, February 27, 2008.

Describe your algorithms as clearly as possible. The style used in the book is fine, as long as your description is not ambiguous. Do not make any assumptions not stated in the problem. If you do make any assumptions, state them clearly, and explain why the assumption does not decrease the generality of your solution. If you use any new words or phrases, define them, especially if we have not used these words/phrases in class. Do not describe your algorithms only for a specific example you may have worked out. You must also provide a clear proof that your solution is correct (or a counter-example, where applicable). Describe an analysis of your algorithm and state its running time.

1. (10 points) Solve the recurrence T(n) = T(√n) + 1 . In words, the T(n) is the running time of an algorithm that creates one sub-problem of the size equal to the square root of n, solves this sub-problem recursively, and spends one more unit of time. You can assume that T(2) = 1 and that n is at least two.
2. (30 points) You are given three algorithms to solve the same problem of size n. Analyse each algorithm in big-O notation. Provide a clear proof of the analysis. Which algorithm would you choose and why? In other words, write down which algorithm is asymptotically the fastest and provide a proof why this algorithm is asymptotically the fastest of all three.
1. Algorithm A solves the problem by dividing it into five subproblems of half the size, recursively solving each subproblem, and then combining the solutions in linear time.
2. Algorithm B solves the problem by dividing it into two subproblems of size n - 1, recursively solving each subproblem, and then combining the solutions in constant time.
3. Algorithm C solves the problem by dividing it into three subproblems of size n/3, recursively solving each subproblem, and then combining the solutions in O(n2) time.
3. (25 points) Solve exercise 1 in Chapter 5 (page 246) of your textbook.
4. (35 points) Solve exercise 3 in Chapter 5 (pages 246-247) of your textbook.