71 71 votes Consider the following two functions: $g_1(n) = \begin{cases} n^3 \text{ for } 0 \leq n \leq 10,000 \\ n^2 \text{ for } n > 10,000 \end{cases}$ $g_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? $g_1(n) \text{ is } O(g_2(n))$ $g_1(n) \text{ is } O(n^3)$ $g_2(n) \text{ is } O(g_1(n))$ $g_2(n) \text{ is } O(n)$ Algorithms gate1994 algorithms asymptotic-notations normal multiple-selects + – Kathleen 26.3k views answer comment Share Follow Print See 1 comment 1 1 comment reply Siddharth_Perkar commented Jun 9 reply Follow flag Fastest GATE Trick Ignore the finite initial range.Look only at what happens for large n. g₁(n) ≈ n² (for n > 10000) g₂(n) ≈ n³ (for n > 100) So asymptotically: g1(n)=Θ(n²) g2(n)=Θ(n³)Option A Check: n² = O(n³)✅ TrueOption B Since, n² = O(n³)✅ TrueOption C Check: n³=O(n²)❌ FalseOption D Check: n³ =O(n)❌ False 0 0 replyShare Please log in or register to add a comment.
Best answer 99 99 votes For asymptotic complexity, we assume sufficiently large $n$. So, $g_1(n) = n^2$ and $g_2(n) = n^3$. Growth rate of $g_1$ is less than that of $g_2$, i.e., $g_1(n) = O(g_2(n)).$ Options $A$ and $B$ are TRUE here. Arjun answered Oct 22, 2014 • edited Jun 24, 2018 by Shikha Mallick Arjun comment Share Follow See all 21 Comments 21 21 Comments reply Show 18 previous comments manas_pant commented Oct 28, 2025 reply Follow flag @jeets if it is less then n^2 then it is less then any function bigger then n^2so n^3 is correct 2 2 replyShare Nithin_Krishna commented Nov 17, 2025 reply Follow flag How option B is correct even though Big-O cares about largest n after 10,000 till infinity it is n^2 ryt? 0 0 replyShare Sanjay Sharma commented Nov 18, 2025 reply Follow flag Big-O means all upper bounds ( both tight and non tight) so if O(n^2) is correct then so is O(n^3). 0 0 replyShare Please log in or register to add a comment.
30 30 votes The answer is given... prithatiti answered Jun 26, 2018 prithatiti comment Share Follow See all 2 Comments 2 2 Comments reply Vink7389 commented Apr 8, 2021 reply Follow flag What should be the value of n here so onwards n, g1(n) = O(g2(n)) always? 2 2 replyShare prithatiti commented Nov 18, 2022 reply Follow flag I think 101 0 0 replyShare Please log in or register to add a comment.
9 9 votes Yes. Both (a) and (b) are correct. $n^{2}$ is $O(n^{3})$. gatecse answered Sep 20, 2014 • edited Oct 16, 2017 by kenzou gatecse comment Share Follow See all 2 Comments 2 2 Comments reply Marv Patel commented Sep 20, 2014 reply Follow flag I though so but when paper says select the correct(only one) choice then it creates doubt! 0 0 replyShare air1ankit commented Nov 24, 2018 reply Follow flag question has only one answer whether you look from left or right. Before 2000 GATE had questions with multiple correct answers and you were given mark only if all are marked. 0 0 replyShare Please log in or register to add a comment.
1 1 vote Index Condition $g_{1}(n)$ $g_{2}(n)$ Time Complexity($B$) Time Complexity($A$) 1 $0 \leq n \leq 100$ $n^{3}$ $n$ $O(n^{3})$ $O(g^{2}(n))$ -- Fails 2 $101 \leq n \leq 10000$ $n^{3}$ $n^{3}$ $O(n^{3})$ $O(g^{2}(n))$ 3 $n \geq 10001$ $n^{2}$ $n^{3}$ $O(n^{3})$ $O(g^{2}(n))$ Thus the right option should be B Avik10 answered Jan 26, 2017 • edited Oct 16, 2017 by kenzou Avik10 comment Share Follow See all 4 Comments 4 4 Comments reply Syedarshadali commented Jan 7, 2018 reply Follow flag Make this best answer 0 0 replyShare Arjun commented Feb 22, 2018 reply Follow flag This is wrong; big-O cares for only large $n$. 2 2 replyShare lokeshsolanki17 commented May 10, 2020 reply Follow flag They are not asking about time complexity in question. They are asking about growth of functions g1(n) and g2(n). g1( n ) = O( g2(n) ) g1(n) <= c.g2(n) ; where n >= N and c > 0 here N value is 10,000. so option A is correct. because after N, g1(n) = n2, and g2(n) = n3 according to option B, g1( n ) = O(n3) is not tight but true because g1(n) belongs to set O(n3).so it is also true 1 1 replyShare MohanK commented Dec 31, 2020 reply Follow flag @lokeshsolanki17, @Arjun Sir, what does it actually meant by “They are not asking about time complexity in question. They are asking about growth of functions g1(n) and g2(n)” ? Isn’t Time complexity inherently uses order of functions ? Is both Time complexity & growth of functions different ? 0 0 replyShare Please log in or register to add a comment.
0 0 votes In asymptotic complexity, we assume sufficiently large n. So, g1(n) = n2 and g2(n) = n3. Growth rate of g1 is less than that of g2 i.e., g1(n) = O(g2(n)) = O(n). Both A and B are True varunrajarathnam answered Aug 7, 2020 varunrajarathnam comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes For asymptotic analysis, we assume sufficiently large value of n i.e n>10,000. For this case, g1(n) = n^2, g2(n) = n^3 clearly, g1(n) = O(g2(n)) = O(n^3). himanshud2611 answered Oct 2, 2023 himanshud2611 comment Share Follow 0 reply Please log in or register to add a comment.