Given the following function, what are the asymptotic running times? Write it in asymptotic notation and justify
Fantastic news! We've Found the answer you've been seeking!
Question:
Given the following function, what are the asymptotic running times? Write it in asymptotic notation and justify why. (, O, ).
def func1(n): x = 0: for i in range(1, n//2+1): for j in range(i, n-1 +1); x = x*x return x |
def func2(n): x = 0 i = 1 while(i < 5*n): for j in range(1, i**2 +1): x = x*i + j i = i + 3 return x |
def func3(n) x = 0 i = 1 while(i < 3*n**7); for j in range(1, i+1); x = x - i*j i = i *3 return s |
def func4(seq): n = len(seq) x = 0 for i in range(n) for j in range(3*(i**2)): x+=i*i - j return x |
def func5(seq) n = len(seq) x = 0 for i in range(n): u = int(4*(n**(1/2))) for j in range(u): x += i*i - j return x |
Related Book For
Posted Date: