# CMPSCI 311: Theory of Algorithms

### Due Friday 26 Sept 2003 in class

#### (or earlier to hand-in box in CMPSCI main office)

All thirteen questions are from [L]. Point values are as indicated. There are 100 total points.

• Question 2.5.2, page 83 (5):

• Question 2.5.7, page 84 (5):

• Question 2.5.9, page 84 (10):

• Question 3.1.2, page 102 (10): Assume that the numbers a and m are Java `int` variables. You might find it convenient to use at least one `long`.

• Question 3.1.4, page 102 (10): For (c), either show how to do it or give an argument that it can't be done using reasonable assumptions (which you should make explicit). Remember that the input to this algorithm is the number x0 together with the entire sequence of coefficients an,...,a0.

• Question 3.2.1, page 105 (10):

• Question 3.2.6, page 106 (5): You need to show that an example exists for every n and every m as long as m ≤ n. It may be easier to start with m=2. Note that the worst-case bound on the number of comparisons is actually (n-m+1)m, not mn. The code in the book, unlike the code I scribbled on the board on 19 September, has an outer loop taking i from 0 through n-m. (That is, `for (i=0; i < n-m+1; i++)`.)

• Question 3.2.7, page 106 (5):

• Question 3.3.6, page 112 (10):

• Question 3.4.1, page 118 (10):

• Question 3.4.7, page 118 (10): Hint: Use a recursive procedure to generate the sets. By "minimizing the number of sets to generate" I think Levitin means a possible factor-of-two optimization.

• Question 4.1.5, page 127 (5): You may either quote the result of the Master Theorem from Appendix B, or guess a solution and prove it correct as we did on Discussion #2.