Professional Documents
Culture Documents
Hw3 Growth of Functions
Hw3 Growth of Functions
Growth of functions
Answer:
(n^2+1) /(n+1) =
(n^2) / n = n
T(n) = O(n)
Q2) Sort the following running time functions in an ascending asymptotic order.
n^1/2, 1000log(n), nlog(n), 2n!, 2^n , 3^n , 1.1^n , n^2 /1000
Answer:
1000log(n) => nlog(n) => n^1/2 => n^2 /1000 => 1.1^n => 2^n => 3^n => 2n!
Q3) Is nlog(n) = Ω(n2 )? Is 2n = Ω(n2 )? Explain your answer for each one.
Answer:
Yes nlog(n) is Ω (n2) because Omega notation provides lower bound for any
algorithm or we can say the time complexity of the best case . For larger value of n ,
n2 is much more larger than nlog(n). So it means we can get solution in Ω (n2).
Q4) Find the big-O notation for the following running time functions
Answer:
To prove 3^n is O(2^n), we must find n0, c such that f(n) <= c*g(n) for all n>=n0
(3/2)^n >= c
For every n >= log 2c/3, 3^n >= 2^n. Therefore, 3^n is not O (2^n).
Answer:
Answer:
Answer:
=> O(n)
Q7) Find the running time function of the following algorithms as we learned in the
class and then the tightest big-O notation.
Answer a):
big-O is O(n)
Answer b):
big-O is O(n^3)
Answer c):
big-O is O(n^2)