logo

Crowdly

Browser

Add to Chrome

How many times will the marked line in the following code run when the size of t...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

How many times will the marked line in the following code run when the size of the input list is n elements?

Note: Just consider the dominant term.

def mystery(n):

res = 0

if n == 0:

return res

else:

i=0

while i < n:

for j in range(n):

res += j # This line

i+=1

return res

Answer in terms of n

0%
0%
0%
0%
More questions like this

Want instant access to all verified answers on learning.monash.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome