Question: Create a Python file named YourLastName _ YourFirstName _ hw 2 . For example, John Smith s file is Smith _ John _ hw 2

Create a Python file named YourLastName_YourFirstName_hw2. For example, John Smiths file is
Smith_John_hw2.py. Calculate the time complexity of each method below and explain the reason. Add
your answers to your Python file as block comments. You dont need to add the methods below to your
Python file. (30 pts)
def func1(n, m):
i =0
while i <100:
print(n)
print(m)
i +=1
def func2(n):
for i in range(n):
for j in range(n//2):
print(i*j)
def func3(n, m):
for i in range(n):
print(i)
for j in range(m):
print(j)
def func4(n, m):
for i in range(n):
for j in range(m):
print(i+j)
def func5(n, m):
i =0
while i < n:
j =1
while j < m:
print(i+j)
j *=3
i +=1
def func6(n):
for i in range(n):
for j in range(n):
print(i+j)
for i in range(n):
print(n+1)
i =1
while i <= n:
print(i)
i *=2

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!