GATE | GATE-CS-2001 | Question 16
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))
Answer: (B)
Explanation: Â
Any constant power of Logn is asymptotically smaller than n.
Proof:
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
Last Updated :
18 Sep, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...