Algorithms | Analysis of Algorithms | Question 19

Which of the given options provides the increasing order of asymptotic complexity of functions f1, f2, f3 and f4?

  f1(n) = 2^n
  f2(n) = n^(3/2)
  f3(n) = nLogn
  f4(n) = n^(Logn)

(A) f3, f2, f4, f1
(B) f3, f2, f1, f4
(C) f2, f3, f1, f4
(D) f2, f3, f4, f1


Answer: (A)

Explanation:

  f1(n) = 2^n
  f2(n) = n^(3/2)
  f3(n) = nLogn
  f4(n) = n^(Logn)

Except f3, all other are exponential. So f3 is definitely first in output. Among remaining, n^(3/2) is next.

One way to compare f1 and f4 is to take Log of both functions. Order of growth of Log(f1(n)) is Θ(n) and order of growth of Log(f4(n)) is Θ(Logn * Logn). Since Θ(n) has higher growth than Θ(Logn * Logn), f1(n) grows faster than f4(n).

Following is another way to compare f1 and f4.

Let us compare f4 and f1. Let us take few values to compare

n = 32, f1 = 2^32, f4 = 32^5 = 2^25
n = 64, f1 = 2^64, f4 = 64^6 = 2^36
...............
............... 

Also see http://www.wolframalpha.com/input/?i=2^n+vs+n^%28log+n%29

Thanks to fella26 for suggesting the above explanation.


Quiz of this Question



My Personal Notes arrow_drop_up

Recommended Posts:



3 Average Difficulty : 3/5.0
Based on 1 vote(s)






User Actions