Skip to content
Official PYQ · 1994

GATE CS 1994 Q1.23 — Asymptotic Worst Case Time and Space Complexity

Explain with AI

Consider the following two functions:

g1(n)={n3 for 0≤n≤10,000n2 for n>10,000g_1(n) = \begin{cases} n^3 \text{ for } 0 \leq n \leq 10,000 \\ n^2 \text{ for } n > 10,000 \end{cases}

g2(n)={n for 0≤n≤100n3 for n>100g_2(n) = \begin{cases} n \text{ for } 0 \leq n \leq 100 \\ n^3 \text{ for } n > 100 \end{cases}

Which of the following is true?

Select all correct options
View worked solution

Answer: A;B

To determine the correct options, we analyze the asymptotic behavior of the functions g1(n)g_1(n) and g2(n)g_2(n) as n→∞n \to \infty. Asymptotic notations like Big-O (OO) describe the behavior of functions for sufficiently large values of nn.

For large values of nn:

  • For n>10,000n > 10,000, the function g1(n)=n2g_1(n) = n^2. Thus, g1(n)=Θ(n2)g_1(n) = \Theta(n^2).
  • For n>100n > 100, the function g2(n)=n3g_2(n) = n^3. Thus, g2(n)=Θ(n3)g_2(n) = \Theta(n^3).

Now, let's evaluate each option:

  1. g1(n) is O(g2(n))g_1(n) \text{ is } O(g_2(n)): This translates to checking if n2=O(n3)n^2 = O(n^3). Since n2≤c⋅n3n^2 \le c \cdot n^3 for all n≥1n \ge 1 (with c=1c=1), this is True.
  2. g1(n) is O(n3)g_1(n) \text{ is } O(n^3): This translates to checking if n2=O(n3)n^2 = O(n^3), which is True.
  3. g2(n) is O(g1(n))g_2(n) \text{ is } O(g_1(n)): This translates to checking if n3=O(n2)n^3 = O(n^2). Since n3n^3 grows strictly faster than n2n^2, this is False.
  4. g2(n) is O(n)g_2(n) \text{ is } O(n): This translates to checking if n3=O(n)n^3 = O(n), which is False.

Thus, the correct options are A and B.

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

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