Question: Write the Big - O notation next to the function for each subquestion below. a . # Assume s is a string with n characters

Write the Big-O notation next to the function for each subquestion below.
a.
# Assume s is a string with n characters
def f(s):
if s =="":
return ""
print(s[:len(s)//2])
return f(s[:len(s)//2])
b.
# Assume s is a string with n characters
def f(s):
x = len(s)
y = s
while x >0:
s = y
while len(s)>0:
s = s[:len(s)//2]
x = x -1
c.
# Assume n is a positive integer
def f(n):
for i in range(n):
print(i)
for j in range(n):
print(j)
for k in range(10):
print(k)
d.
# Assume aList is list containing n items
def f(aList):
for i in range(len(aList)-1,0,-2):
for j in range(i):
print(i, j)
e.
# Assume n is a positive integer
def f(n):
if n <500:
return f(n*3)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!