InterviewSolution
| 1. |
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» Answer: (B) Explanation: Any constant power of Logn is asymptotically smaller than n. Proof: Given f(n) =n2Logn and g(n) = n (logn)10 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). |
|