Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the smallest value of n such that an algorithm whose running time is 100n^2 runs faster than an algorithm whose running time is 2^n? [closed]

Tags:

algorithm

What is the smallest value of n such that an algorithm whose running time is 100n^2 runs faster than an algorithm whose running time is 2^n on the same machine?

The Scope
Although I am interested in the answer, I am more interested in how to find the answer step by step (so that I can repeat the process to compare any two given algorithms if at all possible).

From the MIT Press Algorithms book

like image 499
Nate Neuhaus Avatar asked Oct 17 '14 09:10

Nate Neuhaus


People also ask

What is the smallest value of n such that an algorithm whose running time is 100n 2?

You want the values of n where 100 × n2 is less than 2 × n. Which is the solution of 100 × n2 - 2 × n < 0, which happens to be 0 < n < 0.02 .

What is the smallest value of n such that an algorithm whose running time is 100n 2 runs faster than an algorithm whose running time is 2 n?

What is the smallest value of n such that an algorithm whose running time is 100 n 2 100n^2 100n2 runs faster than an algorithm whose running time is 2 n 2^n 2n on the same machine? For A to run faster than B, 100 n 2 100n^2 100n2 must be smaller than 2 n 2^n 2n.

What is the smallest value of n such that an algorithm whose running time is n 2 runs slower than an algorithm whose running time is 3n 1?

Explanation: For inputs of size n, running time of algorithm A is 100n2 and of B is 2n. For A to run faster than B, 100n2 must be smaller than 2n.

What is the smallest value of n such that an algorithm whose running time is 50n3?

Here running time of algorithms are 50*n3 and 3n ,if we compare both as shown in the following table, we find that 10 is the smallest value of n (9.8) for which 50*n3 will run faster than 3n .


1 Answers

You want the values of n where 100 × n2 is less than 2 × n.

Which is the solution of 100 × n2 - 2 × n < 0, which happens to be 0 < n < 0.02.

One thousand words:

enter image description here

EDIT:

The original question talked about 2 × n, not 2n (see comments).

For 2n, head to https://math.stackexchange.com/questions/182156/multiplying-exponents-solving-for-n

Answer is 15

like image 166
axiom Avatar answered Sep 28 '22 02:09

axiom