23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The number of operations executed by algorithms A<strong>and</strong> B is 8nlogn <strong>and</strong> 2n 2 ,<br />

respectively. Determ<strong>in</strong>e n 0 such that A is better than B for n ≥ n 0 .<br />

R-4.7<br />

The number of operations executed by algorithms A <strong>and</strong> B is 40n 2 <strong>and</strong> 2n 3 ,<br />

respectively. Determ<strong>in</strong>e n 0 such that A is better than B for n ≥ n 0 .<br />

R-4.8<br />

Give an example of a function that is plotted the same on a log-log scale as it is<br />

on a st<strong>and</strong>ard scale.<br />

R-4.9<br />

Expla<strong>in</strong> why the plot of the function n c is a straight l<strong>in</strong>e with slope c on a loglog<br />

scale.<br />

R-4.10<br />

What is the sum of all the even numbers from 0 to 2n, for any positive <strong>in</strong>teger<br />

n?<br />

R-4.11<br />

Show that the follow<strong>in</strong>g two statements are equivalent:<br />

(a)<br />

The runn<strong>in</strong>g time of algorithm A is O(f(n)).<br />

(b)<br />

R-4.12<br />

In the worst case, the runn<strong>in</strong>g time of algorithm A is O(f(n)).<br />

Order the follow<strong>in</strong>g functions by asymptotic growth rate.<br />

R-4.13<br />

4n log n + 2n 2 10 2 logn<br />

3n+100 log n 4n 2 n<br />

n 2 + 10n n 3 n log n<br />

Show that if d(n) is O(f(n)), then ad(n) is O(f(n)), for any constant a>0.<br />

249

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

Saved successfully!

Ooh no, something went wrong!