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
  • Please show the work. I already know the answers, but don't understand how to get there....

    Please show the work. I already know the answers, but don't understand how to get there. 5. Q5. Algorithm Efficiency I. Algorithm A performs (n) binary searches in an array of size n/2. Algorithm B performs e(n) sequential searches in an array of size 4n. Answer the following questions. (a) 1) What is the worst case running time of Algorithm A, in terms of e? (b) [1] What is the worst case running time of Algorithm B, in terms of...

  • Exercise 1 Use Top-Down Design to “design” a set of instructions to write an algorithm for...

    Exercise 1 Use Top-Down Design to “design” a set of instructions to write an algorithm for “travel arrangement”. For example, at a high level of abstraction, the algorithm for “travel arrangement” is: book a hotel buy a plane ticket rent a car Using the principle of stepwise refinement, write more detailed pseudocode for each of these three steps at a lower level of abstraction. Exercise 2 Asymptotic Complexity (3 pts) Determine the Big-O notation for the following growth functions: 1....

  • Using the pseudocode answer these questions Algorithm 1 CS317FinalAlgorithm (A[O..n-1]) ito while i<n - 2 do...

    Using the pseudocode answer these questions Algorithm 1 CS317FinalAlgorithm (A[O..n-1]) ito while i<n - 2 do if A[i]A[i+1] > A[i+2) then return i it i+1 return -1 6. Use limits to show that, for best case inputs, the asymptotic growth of the number of comparisons is (1). Show your work. 7. Use limits to show that, for worst case inputs, the asymptotic growth of the number of comparisons is O(n). Show your work.

  • Subject: Algorithm solve only part 4 and 5 please. need urgent. 1 Part I Mathematical Tools and Definitions- 20 points, 4 points each 1. Compare f(n) 4n log n + n and g(n)-n-n. Is f E Ω(g),fe 0(g)...

    Subject: Algorithm solve only part 4 and 5 please. need urgent. 1 Part I Mathematical Tools and Definitions- 20 points, 4 points each 1. Compare f(n) 4n log n + n and g(n)-n-n. Is f E Ω(g),fe 0(g), or f E (9)? Prove your answer. 2. Draw the first 3 levels of a recursion tree for the recurrence T(n) 4T(+ n. How many levels does it have? Find a summation for the running time. (Extra Credit: Solve it) 3. Use...

  • Please help me with question 13(c,f,h,i,k,m) 13. Show that the following equalities are correct: (a) 5n2...

    Please help me with question 13(c,f,h,i,k,m) 13. Show that the following equalities are correct: (a) 5n2 - 6n(n2) (b) n! - O(n) (c) 2n22"+ n logn-e(n22) (d) I012(n3) (h) 6n3/(log n+1)O(n3) (i) n1.001 + n logn (n1.001) (j) nkte + nk logn 6(nkte) for all fixed k and e, k 0 and e> 0 (1) 33n3 + 4n2 2(n2) (m) 33n3 + 4n23)

  • (V). Given the following algorithm, answer relevant questions. Algorithm 1 An algorithm 1: procedure WHATISTHIS(21,22,...,n: a...

    (V). Given the following algorithm, answer relevant questions. Algorithm 1 An algorithm 1: procedure WHATISTHIS(21,22,...,n: a list of n integers) for i = 2 to n do c= j=i-1 while (j > 0) do if ra; then break end if 4j+1 = a; j= j-1 end while j+1 = 1 end for 14: return 0.02. 1, 15: end procedure Answer the following questions: (1) Run the algorithm with input (41, 02, 03, 04) = (3, 0, 1,6). Record the values...

  • I understand how it was simplified to n^(∈/(sqrt(logn))), but I'm trying to understand how to prove...

    I understand how it was simplified to n^(∈/(sqrt(logn))), but I'm trying to understand how to prove that logn grows faster for 0<∈<1. The derivative seems too complicated to prove this via Lhopital's Rule, so I tried using WolframAlpha to compare the two with logn as the numerator: http://www.wolframalpha.com/input/?i=limit+as+n+approaches+infinity+(logn)%2F(n%5E(0.5%2F(sqrt(logn))))&rawformassumption=%7B%22FunClash%22,+%22log%22%7D+-%3E+%7B%22Log10%22%7D However, this gives me a result of 0 for any value above 0, which would mean that n^(∈/(sqrt(logn))) grows at a faster rate, even when 0<∈<1. When I try to graph it,...

  • (1) Give a formula for SUM{i} [i changes from i=a to i=n], where a is an...

    (1) Give a formula for SUM{i} [i changes from i=a to i=n], where a is an integer between 1 and n. (2) Suppose Algorithm-1 does f(n) = n**2 + 4n steps in the worst case, and Algorithm-2 does g(n) = 29n + 3 steps in the worst case, for inputs of size n. For what input sizes is Algorithm-1 faster than Algorithm-2 (in the worst case)? (3) Prove or disprove: SUM{i**2} [where i changes from i=1 to i=n] ϵ tetha(n**2)....

  • Using the pseudocode answer these questions Algorithm 1 CS317FinalAlgorithm (A[O..n-1]) ito while i<n - 2 do...

    Using the pseudocode answer these questions Algorithm 1 CS317FinalAlgorithm (A[O..n-1]) ito while i<n - 2 do if A[i]A[i+1] > A[i+2) then return i it i+1 return -1 1. Describe what it does and compute what value is returned when the input is the list {1, 2, 3, 4, 5}. (Hint: We're using 0-based array indexing, so 0 would represent the index of the first element, 1 the second element, etc.) 2. Identify and describe the worst-case input. 3. Identify and...

  • please answer these three questions thank you! (e) Given that f(n) € O(n) and g(n) e...

    please answer these three questions thank you! (e) Given that f(n) € O(n) and g(n) e O(n log n), please formally prove that f(n) + g(n) € O(nº). [4 (6) We know that kn is in O(n) for any constant k. Is the following claim correct? Briefly explain. I kn = ŻO(n) = O(n?) 13 o f is a function that satisfies the following: • f is in O(n), . f is in 2(1), • f is neither in e(1)...

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