Let f(n) = n2Logn and g(n) = n (logn)10 be two positive functions of n. Which of the following statements is correct?
(A) f(n) = O(g(n)) and g(n) != O(f(n))
(B) f(n) != O(g(n)) and g(n) = O(f(n))
(C) f(n) = O(g(n)) but g(n) = O(f(n))
(D) f(n) != O(g(n)) but g(n) != O(f(n))
Any constant power of Logn is asymptotically smaller than n.
Given f(n) =n2Logn and g(n) = n (logn)10
In these type of questions, we suggest you to first cancel out the common factor in both the function. After removing these, we are left with f(n) = n and g(n) = (logn)9. Removing a factor of nlogn from both functions.
Now n is very very large asymptotically as compared to any constant integral power of (logn) which we can verify by substituting very large value say 2100.
f(2100) = 2100 = 1030 and g(2100) = 1009 = 1018.
Always remember to substitute very large values of n in order to compare both these functions. Otherwise you will arrive at wrong conclusions because if f(n) is asymptotically larger than g(n) that means after a particular value of n, f(n) will always be greater that g(n).
This solution is contributed by Pranjul Ahuja.
Quiz of this Question