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 />

Next: Implementation Challenges Up: Introduction to <strong>Algorithm</strong>s Previous: War Story: Psychic<br />

Modeling<br />

Exercises<br />

1. Let P be a problem. <strong>The</strong> worst-case time complexity of P is . <strong>The</strong> worst-case time<br />

complexity of P is also . Let A be an algorithm that solves P. Which subset of the<br />

following statements are consistent with this information about the complexity of P?<br />

❍ A has worst-case time complexity .<br />

❍ A has worst-case time complexity .<br />

❍ A has worst-case time complexity O(n).<br />

❍ A has worst-case time complexity .<br />

❍ A has worst-case time complexity .<br />

2. Suppose that an algorithm A runs in worst-case time f(n) and that algorithm B runs in worst-case<br />

time g(n). For each of the following questions, answer either yes, no, or can't tell and explain<br />

why.<br />

(a) Is A faster than B for all n greater than some if ?<br />

(b) Is A faster than B for all n greater than some if ?<br />

(c) Is A faster than B for all n greater than some if ?<br />

(d) Is B faster than A for all n greater than some if ?<br />

(e) Is B faster than A for all n greater than some if ?<br />

(f) Is B faster than A for all n greater than some if ?<br />

3. For each of these questions, briefly explain your answer.<br />

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

some inputs?<br />

file:///E|/BOOK/BOOK/NODE20.HTM (1 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!