Consider the following functions: f(n) = n², if n is even log n, if n is odd…
Consider the following functions:
f(n) = n², if n is even
log n, if n is odd
g(n) = n², if n is odd
log n, if n is even
Which of the following statements is TRUE?
Answer: D. f(n) and g(n) cannot be compared using standard asymptotic notations — Key idea: f(n) and g(n) swap between n² and log n depending on whether n is even or odd, so their ratio behaves very differently on the two parity…
- A.
f(n) = O(g(n))
- B.
f(n) = Θ(g(n))
- C.
f(n) = o(g(n))
- D.
f(n) and g(n) cannot be compared using standard asymptotic notations
Attempted by 284 students.
Show answer & explanation
Correct answer: D
Key idea: f(n) and g(n) swap between n² and log n depending on whether n is even or odd, so their ratio behaves very differently on the two parity subsequences.
For even n: f(n) = n² and g(n) = log n, so f(n)/g(n) = n² / log n → ∞ as n → ∞. Hence f(n) is not O(g(n)).
For odd n: f(n) = log n and g(n) = n², so f(n)/g(n) = log n / n² → 0 as n → ∞. Hence f(n) is not Ω(g(n)).
Conclusion: Because along one infinite subsequence the ratio f(n)/g(n) → ∞ and along another it → 0, there are no constant multiplicative bounds that hold for all sufficiently large n. Therefore none of the standard asymptotic relations (big-O, Theta, little-o, etc.) hold between f and g; the correct statement is that the functions cannot be compared using standard asymptotic notation.
A video solution is available for this question — log in and enroll to watch it.