Skip to content
Official PYQ · 2000

GATE CS 2000 Q2.17 — Asymptotic Worst Case Time and Space Complexity

Explain with AI

Consider the following functions

  • f(n)=3nnf(n) = 3n^{\sqrt{n}}
  • g(n)=2nlog⁡2ng(n) = 2^{\sqrt{n}{\log_{2}n}}
  • h(n)=n!h(n) = n!

Which of the following is true?

Choose one option
View worked solution

Answer: D

To find the correct relationship between the given functions, let us analyze and simplify them asymptotically:

  1. Analyze f(n)f(n) and g(n)g(n):

    We are given:

    f(n)=3nnf(n) = 3n^{\sqrt{n}} g(n)=2nlog⁡2ng(n) = 2^{\sqrt{n}\log_{2}n}

    Using the identity n=2log⁡2nn = 2^{\log_{2}n}, we can rewrite f(n)f(n) as:

    f(n)=3⋅(2log⁡2n)n=3⋅2nlog⁡2nf(n) = 3 \cdot \left(2^{\log_{2}n}\right)^{\sqrt{n}} = 3 \cdot 2^{\sqrt{n}\log_{2}n}

    Comparing this with g(n)g(n):

    f(n)=3⋅g(n)f(n) = 3 \cdot g(n)

    Since f(n)f(n) is a constant multiple of g(n)g(n), they grow at the exact same rate asymptotically. Thus:

    f(n)=Θ(g(n))f(n) = \Theta(g(n))

    This implies both of the following are true:

    • f(n)=O(g(n))f(n) = O(g(n))
    • g(n)=O(f(n))g(n) = O(f(n))
  2. Analyze h(n)h(n):

    We have h(n)=n!h(n) = n!. By Stirling's approximation, n!≈2πn(ne)nn! \approx \sqrt{2\pi n} \left(\frac{n}{e}\right)^n, which grows much faster than nnn^{\sqrt{n}}. Therefore, h(n)h(n) is strictly larger than both f(n)f(n) and g(n)g(n) asymptotically, meaning h(n)h(n) is neither O(f(n))O(f(n)) nor O(g(n))O(g(n)).

Let us evaluate the given options:

  • A. h(n)h(n) is O(f(n))O(f(n)): False, because h(n)h(n) grows much faster than f(n)f(n).
  • B. h(n)h(n) is O(g(n))O(g(n)): False, because h(n)h(n) grows much faster than g(n)g(n).
  • C. g(n)g(n) is not O(f(n))O(f(n)): False, since g(n)=O(f(n))g(n) = O(f(n)) is true.
  • D. f(n)f(n) is O(g(n))O(g(n)): True, since f(n)=3⋅g(n)f(n) = 3 \cdot g(n).

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

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