in Theory of Computation retagged by
435 views
1 vote
1 vote

if f(n) = O(n2) and g(n) = O(n3), then

what is the complexity of f(n)*g(n) and f(n)/g(n) in big-o-notation?

in Theory of Computation retagged by
435 views

2 Answers

1 vote
1 vote

Given f(n)=O(n$^{2}$) and g(n)=O(n$^{3}$)

Hence as per definition,

f(n)<=c*n$^{2}$, f(n) can be n$^{2}$, n$^{2}$/logn, nlogn,n,constant,1/n,1/n$^{2}$,1/2$^{n}$,...

Similarly,

g(n)<=c*n$^{3}$, f(n) can be n$^{3}$, n$^{2}$, nlogn,n,constant,1/n,1/n$^{2}$,1/2$^{n}$,...

Solution:

[I] f(n)*g(n) <= [constant *largest possibile eqn in f(n) ]*[constant *largest possibile eqn in g(n) ]=constant*n$^{2}$*constant*n$^{3}$

i.e. f(n)*g(n)<=c*n$^{5}$,

Hence f(n)*g(n)=O(n$^{5}$).

[II] f(n)/g(n) <= [constant *largest possibile eqn in f(n) ] [constant *smallest eqn in g(n) ]

Since the lowest equation is not bounded for g(n), it can be 1/n, 1/n!,1/2$^{n}$,1/n$^{n}$, and even lower than that

Hence f(n)/g(n) does not have an upper bound. 

0 votes
0 votes

 f(n) = O(n2)

 g(n) = O(n3)

 f(n) * g(n) = O(n^2)  * O(n^3) = O(n^5)

f(n) / g(n)  = O(n^2) /  O(n^3) = O(1/n)

3 Comments

The book says that f(n)*g(n) = O(n^6). (I think it might be an error but need clarification).

And in case of division, I think it should be O(n^2) because we need to take the maximum of numerator and minimum of denominator so as to get the worst case.

Please someone verify.
0
0

why f(n) * g(n) = O(n^2)  * O(n^3) = O(n^5) and f(n) / g(n)  = O(n^2) /  O(n^3) = O(1/n) ?

We are basically calculating f(n) and g(n) and then doing one operation (multiplication or division).

Calculating f(n) will take O(n2)  and calculating g(n) will take O(n3) . Then mult or div will take constant time O(1).

So,

f(n) * g(n) = O(n^2)  + O(n^3) + O(1) = O(n^3)

f(n) / g(n) = O(n^2)  + O(n^3) + O(1) = O(n^3)

1
1
big O means maximum possible means worst case possible in the case of multiplication worst case should be possible o(n^5). but in the case of division it should be O(n^3) why because for worst case (f(n)/g(n)) f(n) should be maximum and g(n) should be minimum given that f(n)=O(N^3) so maximum is n^3 and g(n)=O(n^2)[value possible 1 to n^2] for minimum  we have to take g(n)=1 then in this case f(n)/g(n)=O(n^3).
0
0