Suppose that you have two different algorithms for solving a problem. To solve a problem
of size n, the first algorithm uses exactly n (log n) operations and the second algorithm uses
exactly n to the power (3/2) operations. As n grows, which algorithm uses fewer operations?

Respuesta :

Answer:

First algorithm will have fewer comparison than second as the value of n grows.

Step-by-step explanation:

As n grows, first algorithm will perform better then other.

Consider the ratio of number of comparison done by second algorithm with number of comparison done by first algorithm, the ratio will be [tex]$n^{3 / 2} /(n \log (n))=\sqrt{n} / \log n=\log 2^{\sqrt{n}} / \log n$[/tex]

Since log function is monotonically increasing function and [tex]$2^{\sqrt{n}}>n$[/tex] for all [tex]$n>4$[/tex]. Hence first algorithm will have fewer comparison than second as the value of n grows.

RELAXING NOICE
Relax