Search code examples
algorithmexecution

which one of these algorithm take more time?


I have these algorithm and I didn't find out which one takes more time.

O((n^2)*log(n))

O(n*(2^n))

I calculate the log of those but I can't understand which one takes more time.

log((n^2)*log(n)) = 2log(n)+log(log(n))

log(n*(2^n))=log(n)+n*log(2)


Solution

  • The second one, because:

    2^n > n^2
    

    and

    n > log(n)