18.04.2013 Views

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Exercises<br />

(b) If I prove that an algorithm takes worst-case time, is it possible that it takes O(n) on all<br />

inputs?<br />

(c) If I prove that an algorithm takes worst-case time, is it possible that it takes O(n) on<br />

some inputs?<br />

(d) If I prove that an algorithm takes worst-case time, is it possible that it takes O(n) on all<br />

inputs?<br />

(e) Is the function , where for even n and for odd<br />

n?<br />

4. For each of the following, answer yes, no, or can't tell. Explain your reasoning!<br />

(a) Is ?<br />

(b) Is ?<br />

(c) Is ?<br />

(d) Is ?<br />

5. (*) Give a proof or counterexample to the following claim: if f(n) = O(F(n)) and g(n) = O(G(n)),<br />

then f(n)/g(n) = O(F(n)/G(n)).<br />

6. (*) Does f(n) = O(g(n)) imply that ? Explain your reasoning!<br />

7. (*) Give a proof or counterexample to the following claim: for all functions f(n) and g(n), either<br />

f(n) = O(g(n)) or g(n) = O(f(n)).<br />

8. (*) When you first learned to multiply numbers, you were told that means add x a total of y<br />

times, so . What is the time complexity of multiplying two n-digit<br />

numbers in base b (people work in base 10, of course, while computers work in base 2) using the<br />

repeated addition method, as a function of n and b. Assume that single-digit by single-digit<br />

addition or multiplication takes O(1) time. (hint: how big can y be as a function of n and b?)<br />

9. (*) In grade school, you learned to multiply long numbers on a digit by digit basis, so that<br />

. Analyze the time complexity of multiplying<br />

two n-digit numbers with this method as a function of n (assume constant base size). Assume that<br />

single-digit by single-digit addition or multiplication takes O(1) time.<br />

file:///E|/BOOK/BOOK/NODE20.HTM (2 of 3) [19/1/2003 1:28:20]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!