Question

Given a algorithm with f(n) 5n2 + 4n + 14 in the worst case, f(n) 3n2 + 17 log, n + 1in the average case, and f(n) in 17 the

Please provide solution/methods so I can understand how this work.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Lets consider theta notation since it provide asymptotic upper and lower bounds.
if f(n) = Theta(g(n)) then there exist c1, c2 and n0 such that

c1*g(n) <= f(n) <= c2*g(n) for all n>=n0

and c1, c2>0 , n0>=0

We know that logn and n terms are asymptotically smaller than n^2.


lets assume g(n) = n^2

So for all cases,

limit n-> infinity g(n)/f(n) = n^2/(con*n^2 + smaller terms than n^2)

limit n-> infinity g(n)/f(n) = 1/(con + (small terms) / n^2) = 1/con which is constant. That means they grow at similar rate

where con = 5, 3, 1/17 for worst, average and best case

Now let c1 = 1 and c2=10

c1*g(n) = n^2 / 18 <= f(n) in best, worst and average case
c2*g(n) = 10*n^2 >= f(n) in best, worst and average case
and n0 = 100 or 1000 maybe (works for both)

(10n^2 > 5n^2 + 4n + 14 and similarly for other cases)
(n^2/18 < 5n^2 + 4n + 14 and similarly for other cases)

so we have f(n) = Theta(n^2) which provide tight bounds for f(n)

Option B) is correct

to disprove other options, we can see that bounds can provide upper or lower limit correctly
like option K) Theta(n^2 logn) this can provide upper bound but not lower


Add a comment
Know the answer?
Add Answer to:
Please provide solution/methods so I can understand how this work. Given a algorithm with f(n) 5n2...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT