Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the same operation - counting rules and Python program we saw in the last video's question: Each addition and subtraction costs 1 Each comparison

Consider the same operation-counting rules and Python program we saw in the last video's question:
Each addition and subtraction costs 1
Each comparison (a > b) costs 1
Everything else is free
7
def fun(n,x):
counter = n
amount =0
while counter >0:
amount = amount + x
counter = counter -1
return amount
As we saw before, the cost of calling this function, by the above rules, is 3n +1.
What is the smallest expression g such that the cost of calling the function is O(g)?

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

Global Strategy

Authors: Mike W. Peng

5th Edition

0357512367, 978-0357512364

More Books

Students also viewed these Programming questions

Question

How is ????1 different from ????1?

Answered: 1 week ago

Question

=+c. Calculate and interpret the coefficient of determination.

Answered: 1 week ago

Question

=+c. Construct a plot of the residuals. What does it suggest?

Answered: 1 week ago