12.07.2015 Views

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

SHOW MORE
SHOW LESS
  • No tags were found...

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

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

Sec. 3.13 Exercises 913.3 Arrange the following expressions by growth rate from slowest <strong>to</strong> fastest.4n 2 log 3 n n! 3 n 20n 2 log 2 n n 2/3See Stirling’s approximation in Section 2.2 for help in classifying n!.3.4 (a) Suppose that a particular algorithm has time complexity T(n) = 3 ×2 n , <strong>and</strong> that executing an implementation of it on a particular machinetakes t seconds for n inputs. Now suppose that we are presented with amachine that is 64 times as fast. How many inputs could we process onthe new machine in t seconds?(b) Suppose that another algorithm has time complexity T(n) = n 2 , <strong>and</strong>that executing an implementation of it on a particular machine takest seconds for n inputs. Now suppose that we are presented with a machinethat is 64 times as fast. How many inputs could we process onthe new machine in t seconds?(c) A third algorithm has time complexity T(n) = 8n. Executing an implementationof it on a particular machine takes t seconds for n inputs.Given a new machine that is 64 times as fast, how many inputs couldwe process in t seconds?3.5 Hardware vendor XYZ Corp. claims that their latest computer will run 100times faster than that of their competi<strong>to</strong>r, Prunes, Inc. If the Prunes, Inc.computer can execute a program on input of size n in one hour, what sizeinput can XYZ’s computer execute in one hour for each algorithm with thefollowing growth rate equations?n n 2 n 3 2 n3.6 (a) Find a growth rate that squares the run time when we double the inputsize. That is, if T(n) = X, then T(2n) = x 2(b) Find a growth rate that cubes the run time when we double the inputsize. That is, if T(n) = X, then T(2n) = x 33.7 Using the definition of big-Oh, show that 1 is in O(1) <strong>and</strong> that 1 is in O(n).3.8 Using the definitions of big-Oh <strong>and</strong> Ω, find the upper <strong>and</strong> lower bounds forthe following expressions. Be sure <strong>to</strong> state appropriate values for c <strong>and</strong> n 0 .(a) c 1 n(b) c 2 n 3 + c 3(c) c 4 n log n + c 5 n(d) c 6 2 n + c 7 n 63.9 (a) What is the smallest integer k such that √ n = O(n k )?

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

Saved successfully!

Ooh no, something went wrong!