Math Problem Statement
Problem 13.
What is the time complexity of the following function? State your answer as a function of n using asymptotic
notation in the simplest form possible. E.g., “Θ(n)”.
from math import sqrt, log, ceil
def foo(n):
for i in range(ceil(n**3 - 10*n + sqrt(n))):
for j in range(ceil(log(n**2) + sqrt(n))):
print(i, j)
Problem 14.
What is the expected time complexity of the function below? State your answer using asymptotic notation.
import random
def foo(n):
draw a random number uniformly from 0, 1, 2, ..., 99
in constant time
x = random.randrange(100)
for i in range(x**2):
for j in range(n):
print("Hi!")
Solution
Ask a new question for Free
By Image
Drop file here or Click Here to upload
Math Problem Analysis
Mathematical Concepts
Time Complexity
Asymptotic Notation
Nested Loops
Formulas
-
Theorems
-
Suitable Grade Level
Undergraduate
Related Recommendation
Sorting Functions by Asymptotic Complexity: Understanding Big-O Notation
Understanding Time Complexity of Python Factorial Function
Analyzing Java Code: Understanding Nested Loops and Time Complexity
Solving 10 Advanced Math Problems with Detailed Solutions
Comparing Growth Rates of Functions - Algorithm Analysis