Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

what is the worst-case run-time complexity of the following function? def f_15(lst): # lst is a Python list res = 0 for x in lst:

what is the worst-case run-time complexity of the following function?

def f_15(lst): # lst is a Python list

res = 0

for x in lst:

res += res

return res

(a) O(1)

(b) O(log N)

(c) O(N)

(d) O(N^2)

def f_16(lst): # lst is a Python list

res = 0

for x in range(100):

res += lst[randrange(len(lst))]

return res

(a) O(1)

(b) O(log N)

(c) O(N)

(d) O(N^2)

def f_17(lst): # lst is a Python list

res = 0 bot, top = 0, len(lst)

while bot < top:

mid = (bot + top) // 2

res += lst[mid]

if res < 0:

bot = mid + 1

else:

top = mid - 1

return res

(a) O(1)

(b) O(log N)

(c) O(N)

(d) O(N^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

Step: 3

blur-text-image

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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

What impediments deal with regulators?

Answered: 1 week ago

Question

What are their performance levels?

Answered: 1 week ago