1 / 7

Assignment 2

Assignment 2. Tze calculations. If a and b are constant, real numbers then loga n and logb n differ by a constant factor. What is the value of this constant?. Suppose the exact time required for an algorithm A is given by the equation above:

rex
Download Presentation

Assignment 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Assignment 2 Tze calculations

  2. If a and b are constant, real numbers then loga n and logb n differ by a constant factor. What is the value of this constant?

  3. Suppose the exact time required for an algorithm A is given by the equation above: • a) Give a valid time complexity for A in big-O notation. • b) Give a second (different) time complexity for A in big-O notation. • c) Give the time complexity for A in big- notation.

  4. Use the definition of big-O to prove the above equation • Hint: you need to find a specific c and n0 (as in the definition for big-O) such that f(n) < cn2 for all n > n0.

  5. a) Determine the exact number of statements that are executed when we run this code fragment as a function of n. Show all of your calculations. • b) Express the function you obtained in part a) in big-O notation.

  6. a) Determine the exact number of statements that are executed when we run this code fragment in the worst case. Your answer should be a function of n = a:length. Show all of your calculations. • b) Determine one or more active operations. Find the number of times the active operation(s) are executed. Your answer should be a function of n = a:length. Show all of your calculations (refer back to calculations in part a) if need be, don't repeat arguments unnecessarily). • c) Express the functions obtained in parts a) and b) in Big-O notation.

More Related