Question

Algorithm A performs {eq}10n^2

{/eq} basic operations, and algorithm B performs 300ln(n) basic operations. For what value of n does algorithm B start to show its better performance?

EXPERT ANSWER

Algorithm B has a better complexity in terms of its input size. Algorithm B starts to show its better performance for any value of *n’>3*.

For example, if we assign *n=3*, this is the performance of both algorithms:

Algorithm A:

10 * n^2

n=3

10 * 9