1 1 vote What is the order of growth of $\texttt{bar}$ in terms of $\texttt{n}$?def bar(n): i, sum = 1, 0 while i <= n: sum += biz(n) i += 1 return sum def biz(n): i, sum = 1, 0 while i <= n: sum += i**3 i += 1 return sumConstantLogarithmicLinearQuadraticExponentialNone of these Algorithms goclasses goclasses-da-dpp goclasses-da-dpp-day-217 python-&-dsa goclasses-python-&-dsa-practice-questions time-complexity + – GO Classes 122 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
1 1 vote In $\texttt{bar(n)}$, the outer loop runs $\texttt{n}$ times.In each iteration, $\texttt{biz(n)}$ is called.In $\texttt{biz(n)}$, the loop also runs $\texttt{n}$ times. The expression $\texttt{i**3}$ does not make the loop cubic, because $\texttt{i}$ is still increasing by $\texttt{1}$.bar loop $: \text{n}$ timesbiz loop $: \text{n}$ timesTotal $\mathrm{= n * n = n^2}$Therefore, the order of growth is Quadratic.Correct Option: D GO Classes answered Jul 6 GO Classes comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes def bar(n): i, sum = 1, 0 while i <= n: # runs n times sum += biz(n) # takes O(n) time i += 1 return sum def biz(n): i, sum = 1, 0 while i <= n: # runs n times sum += i**3 i += 1 return sum$N*O(N) = O(N^2)$Answer: D. Quadratic Meticulous_March answered Jul 6 Meticulous_March comment Share Follow 0 reply Please log in or register to add a comment.