Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7. If f(n) is a function that gives the run time for an algorithm on inputs of size n, it's natural to assume that f(n)

image text in transcribed
7. If f(n) is a function that gives the run time for an algorithm on inputs of size n, it's natural to assume that f(n) is increasing, that is, bigger inputs take more time to process. But not all functions are increasing. Suppose we define f(n) = 1 when n is even and f(n) =n2 when n is odd. If you look at the sequence of values of f, they would be: 12,1,3, 1,5, 1,7,1,9-, 1.,... a) Explain why f(n) = 0(n2), using the definition of Big O. b) Explain why f(n) (n2), using the definition. (That is, it is not possible to find a positive constant c such that f(n) 2 en2 for all large enough values of n, no matter how small you make c.) c) write a function, int g(int n), whose run time for n > 0 is (f(n), where f(n) is the function given above. Your function doesn't need to do ahything interesting. (Note that since f(n) (n2) but f(n)(n2), it is also true that f(n) 6(). According to the definition on page 39 of the textbook, this means that f(n)

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

Mastering Big Data Interview 751 Comprehensive Questions And Expert Answers

Authors: Mr Bhanu Pratap Mahato

1st Edition

B0CLNT3NVD, 979-8865047216

More Books

Students also viewed these Databases questions

Question

Explain the factors affecting dividend policy in detail.

Answered: 1 week ago

Question

Explain walter's model of dividend policy.

Answered: 1 week ago

Question

5. How would you describe your typical day at work?

Answered: 1 week ago

Question

7. What qualities do you see as necessary for your line of work?

Answered: 1 week ago