Question

Suppose that Algorithm A has runtime complexity O(n3) and Algorithm B has runtime complexity O(n logn), where both algorithms solve the same problem. (a) How do the algorithms compare when n = 12? (b) How do the algorithms compare when n is very large?

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

a)

for n = 12

A takes O(12^3) = 1728

B takes O(12log12) = 43

So, B is more efficient than A

b)

for very larger n, nlogn is always more efficient than n^3, so B is always faster than A

Add a comment
Know the answer?
Add Answer to:
Suppose that Algorithm A has runtime complexity O(n3) and Algorithm B has runtime complexity O(n logn),...
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 give me a divide and conquer algorithm that has runtime better than O(n^2) along with...

    Please give me a divide and conquer algorithm that has runtime better than O(n^2) along with justification. Also please do a runtime analysis on this algorithm. Please DONT copy and paste other's solution.THANKS 3. Give the best algorithm you can to convert an n digit number base 10 into binary. Here, we are counting operations on single digits as single steps, not arithmetic operations. You can use any of the multiplication algorithms we described in class.)

  • 11 QUESTION 11 What is the runtime of Binary Search? a. O(n) b. Onlogn) c. Of(logn))...

    11 QUESTION 11 What is the runtime of Binary Search? a. O(n) b. Onlogn) c. Of(logn)) d. Odlogn)

  • Determine the runtime complexity of the following. Use O() notation, but the function that you place within the parenthe...

    Determine the runtime complexity of the following. Use O() notation, but the function that you place within the parentheses of O() should be the upper bound on the runtime of the algorithm or function. Unless otherwise specified, N is the problem size or the number of elements in the container (even if N does not appear in the code or algorithm you are given), and all other values are constants. For graphs, use |V| and |E| for the size of...

  • You are running algorithm with squared complexity on data with 100 elements and it takes 10...

    You are running algorithm with squared complexity on data with 100 elements and it takes 10 seconds. How much time do you expect the algorithm will take when executed on data with 1000 elements? Order the following: O(n2), O(12 + 7n), O(n log(n) + 300 n2 + 1/125 n3)

  • (d) Consider an algorithm A, whose runtime is dependent on some "size" variable n of the...

    (d) Consider an algorithm A, whose runtime is dependent on some "size" variable n of the input. Explain the difference between the two statements below, and give an explicit example of an algorithm for which one statement is true but the other is false. 1. The worst case time complexity of A is n2. 2. A is O(n). (e) Give an example of an algorithm (with a clear input type) which has a Big-Oh (0) and Big-Omega (12) bound on...

  • Please find the complexity of the algorithm used to solve the problem below. Also find the...

    Please find the complexity of the algorithm used to solve the problem below. Also find the approximate problem size we could solve in time t, given that we double the speed of the original machine. Thank you Suppose that a computer can run an algorithm on a problem of size 1,024 in time t. We do not know the complexity of the algorithm. We note that when we run the same algorithm on a computer 8 times faster, in the...

  • 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,...

  • Therefore, getx-log,n from 2on. So the time complexity of this loop is O logn). Eliminate low...

    Therefore, getx-log,n from 2on. So the time complexity of this loop is O logn). Eliminate low order terms 26 00:01 00:01 Homework #7 Homework #7 - 7.1 Design the algorithm of Towers of Hanoi. . Source peg, Destination peg, Auxlary peg s k disks on the source peg, a bigger disk can never be on top of a smaler dsk : Need to move al k disks to the destination peg using the auxillary peg, without ever keeping a bigger...

  • Suppose we have two algorithms A1 and A2 for solving the same problem. Let T_1(n) be...

    Suppose we have two algorithms A1 and A2 for solving the same problem. Let T_1(n) be the worst case time complexity of Algorithm A1 and T_2(n) be the worst case time complexity of Algorithm A2. We know that T_1(1) = 1 and T_1(n) = 8 middot T_1(n/2) + 100n^2. We also know that T_2(1) = 1 and T_2(n) = 63 middot T_2(n/4) + 200 middot n^2. Use the master method to decide T_1(n). Follow all the steps as illustrated in...

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