70 likes | 165 Views
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:
E N D
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: • 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.
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.
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.
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.