Skip to content
Official PYQ · 2008

GATE CS 2008 Q39 — Asymptotic Worst Case Time and Space Complexity

Explain with AI

Consider the following functions:

  • f(n)=2nf(n) = 2^n
  • g(n)=n!g(n) = n!
  • h(n)=nlog⁡nh(n) = n^{\log n}

Which of the following statements about the asymptotic behavior of f(n)f(n), g(n)g(n) and h(n)h(n) is true?

Choose one option
View worked solution

Answer: D

To compare the growth rates of the functions f(n)=2nf(n) = 2^n, g(n)=n!g(n) = n!, and h(n)=nlog⁡nh(n) = n^{\log n}, we can take the base-2 logarithm (log⁡2\log_2) of each function for large nn:

  1. For h(n)=nlog⁡2nh(n) = n^{\log_2 n}:log⁡2(h(n))=log⁡2(nlog⁡2n)=(log⁡2n)2\log_2(h(n)) = \log_2\left(n^{\log_2 n}\right) = (\log_2 n)^2
  2. For f(n)=2nf(n) = 2^n:log⁡2(f(n))=log⁡2(2n)=n\log_2(f(n)) = \log_2(2^n) = n
  3. For g(n)=n!g(n) = n!:
    Using Stirling's approximation, log⁡2(n!)≈nlog⁡2n−nlog⁡2e\log_2(n!) \approx n \log_2 n - n \log_2 e. Thus:log⁡2(g(n))=Θ(nlog⁡n)\log_2(g(n)) = \Theta(n \log n)

Comparing the growth rates of these logarithmic values for sufficiently large nn:

(log⁡2n)2<n<nlog⁡2n(\log_2 n)^2 < n < n \log_2 n

Since the logarithm function is strictly increasing, the original functions follow the same ordering in terms of asymptotic growth rate:

h(n)<f(n)<g(n)h(n) < f(n) < g(n)

From this ordering, we can establish the following relations:

  • Since h(n)h(n) grows slower than f(n)f(n), we have h(n)=O(f(n))h(n) = O(f(n)).
  • Since g(n)g(n) grows faster than f(n)f(n), we have g(n)=Ω(f(n))g(n) = \Omega(f(n)).

This matches the statements in Option D.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Asymptotic Worst Case Time and Space Complexity questions