Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For each of the following methods, determine the runtime in Big-Oh Notation. Choose from the Following: O(1) O(log n) O(n) O(n log n) O(n^2) O(n^3)

For each of the following methods, determine the runtime in Big-Oh Notation. Choose from the Following:

O(1)

O(log n)

O(n)

O(n log n)

O(n^2)

O(n^3)

O(n!)

A)

def m1(n): factorial = 1 for i in range(1, n+1): factorial *= i return factorial

B) def m2(lst): n = len(lst) for e1 in lst: for e2 in lst: for e3 in lst: if e1 == e2 == e3: print("equal")

C)

def m3(lst): n = len(lst) for e1 in lst: print(e1) for e2 in lst: print(e2) for e3 in lst: print(e3)

D)

def m4(lst): n = len(lst) for i in range(10): print(lst[ i ])

E)

def m5(lst): n = len(lst) copy = lst.copy() while len(copy) > 0: print(len(copy)) copy = copy[0:int(len(copy)/2)]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

Explain online impression management activities

Answered: 1 week ago