# CMPSCI 311: Theory of Algorithms

### Due Friday 19 Sept 2003 in class

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

All questions except the last are from [L]. Point values are as indicated. There are 100 total points plus 10 extra credit.

• Question 2.2.1, page 59 (5):

• Question 2.2.3, page 60 (10): Prove each conclusion by giving explicit numbers c and n0, following the definition of big-0. (Actually the conclusion is about big-Theta, so you need a c and an n0 to prove the big-O and then another c and another n0 to prove the big-Omega. Of course you can use the same n0 for both if it works. (Clarification added 16 September 2003.)

• Question 2.2.4, page 60 (10): For (b), you must prove that log n is in O(n) but that n is not in O(log n), that n is in O(n log n) but n log n is not in O(n), and so forth for each pair of functions that are adjacent in the list. It is probably easiest to use the calculus-based methodology described on page 54.

• Question 2.2.5, page 60 (5):

• Question 2.2.8, page 60 (10):

• Question 2.2.10, page 61 (10XC): Here is a wrong way to do it -- go one step left, then two steps right, then three steps left, then four steps right, and so on until you find the target. This will definitely reach the target eventually but does not meet the desired O(n) bound on the number of steps.

• Question 2.3.1, page 67 (5):

• Question 2.3.4, page 68 (10):

• Question 2.3.10, page 69 (5): Note that the "glaring inefficiency" costs a multiplicative constant factor, and that fixing it does not change the big-O time of the algorithm.

• Question 2.4.1, page 76 (10):

• Question 2.4.4, page 76-77 (5):

• Question 2.4.8 and 2.4.9, page 77-78 (10 total):

• Question 2.4.10, page 78 (5):

• Question B1, not in book (10): Let g be a function from positive integers to reals. Define Z(g) to be the class of functions {f: ∃c∃n0∃d ∀n≥n0: f(n)≤cg(n)+d}. Recall that O(g) is the class of functions {f: ∃c∃n0∀n≥n0: f(n)≤cg(n)}. Prove that Z(g) = O(g), that is, that a function f is in one class if and only if it is in the other.

As I mentioned in class, proving this result allows us to later prove that f is in O(g) by proving the easier condition to show f in Z(g).